AnonymousCodeholic
unread,Apr 19, 2012, 3:57:43 AM4/19/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to spymemcached
First of all, thanks for a great library. I've been using it
successfully for years in various Internet-scale applications.
In MemcachedClient there are synchronous methods (synchronous ==
blocks until response is received from Memcache or until an error
occurs) for reading data from Memcache, e.g. "Object get(String key)".
Additionally there are correspoidng asynchronous methods like
"Future<Object> asyncGet(String key)". In the implementation
synchronous get is a layer on top of the asynchronous get.
In the put-side (storing data in Memcache), the implementation is
different. The write-methods (e.g. "public OperationFuture<Boolean>
set(String key, int exp, Object o)") are asynchronous. There are no
synchronous write-methods.
IMHO this is misleading - it'd be more consistent if the write methods
would be synchronous and there'd be asyncSet and similar methods for
asynchronous operation. However, the naming is not my problem. My
problem is that there are no synchronous write-operations.
There are use cases when a synchronous mode is needed. Consider a case
where in a web application, Memcache is used for storing user session
data and there are multiple application servers. In this case Memcache
is not used as "a cache" but as a kind of shared memory. In this case
it's important that the session data is correctly updated in Memcache
after each HTTP request. Now, since set() is asynchronous it's
possible that because of e.g. network congestion the set() operation
from one app server doesn't reach Memcache before the session data is
read in another app server. This causes session data to get corrupted.
A synchronous set is needed to ensure consistency.
Currently to make synchronous write operations the app developer needs
to do things like:
memcacheClient.set(key, duration, value).get(100,
TimeUnit.MILLISECONDS);
It'd be better to have in the MemcacheClient a method
synchronousSet(key, duration, value);
That would use the same default timeout as the synchronous get uses.
Please consider having synchronous put (and other write-method) in the
future releases.
r,
J