|
|
On Thu, Feb 21, 2008 at 20:31:52 +0100, Kostas Chatzikokolakis wrote:
> I'd like to ask wether Cache::Memcached::Fast keeps connections to
> memcached servers open, and if so, does it reconnect in case a
> connection drops?
Yes for both questions. Upon the request to a particular server
(which servers will be used depends by requested keys), if there's no
connection to the server yet, C::M::F connects to it (or gives up
after connect_timeout seconds). The module doesn't close the
connection until either:
- C::M::F is destroyed.
- server sends error CLIENT_ERROR, SERVER_ERROR, ERROR, and
close_on_error is set (default). These errors are very unlikely
to happen, but when they do, it's better to close the connection
to avoid out-of-sync protocol state.
- connection drops.
Connection drop is detected during request processing. In this case
C::M::F closes it's local endpoint, and request processing is
continued unless all requested servers are dead. Then everything
starts from the beginning: when the new request comes C::M::F again
sees that there's no connection to the server, and tries to reconnect.
You will likely want to set
max_failures => 1,
failure_timeout => 5,
where 5 is number of seconds after failure during which no reconnect
attempt will be maid in order to not waste all the time trying to
reconnect to dead memcached over and over again.
As said above, failure of one server does not affect the requests to
other servers. In particular multi-key request will succeed for all
keys but those dispatched to the failed server.
> I want to use the module under mod_perl, and the natural thing to do is
> to keep a pool of C::M::F objects in a global hash, to avoid creating a
> new object in each request (similarly to what Apache::DBI does for DBI).
AFAIK some people use it exactly this way.
--
Tomash Brechko
|
|