2. You don't want it to.
http://code.google.com/p/memcached/wiki/FAQ#When_do_expired_cached_items_get_deleted_from_the_cache?
Having to have a garbage collector that watched items for expiration
would increase the load that memcached put on a system a great deal.
Brian.
--------
http://brian.moonspot.net/
--
"Be excellent to each other"
I simply want to use memcached to store user sessions for multiple web
app servers, instead of using the tomcat's local session.
Tomcat supports something call HttpSessionListener which has a
listener method "sessionDestroyed" that allows a last chance clean up
before the session object is destroyed.
I know tomcat has ways to replicate sessions over multiple servers but
i am thinking memcached is an easier solution for that.
If you know some other better option please let me know.. thx.
On Aug 23, 10:08 am, Henrik Schröder <skro...@gmail.com> wrote:
> Basically, no, but there are ways you can do that yourself in your
> application. However, it still sounds like you're using memcached for
> something it was not designed to do. It is a cache, not a datastore. You are
> never guaranteed to get back an item that you have stored, and you have no
> way of knowing if a cache miss is because the item expired, or because it
> was never stored in the first place.
>
> But what you can do is to store a timestamp yourself together with the item.
> Then, whenever you retrieve the item, you look at your timestamp and treat
> it as the actual expiry, so if it's passed, you perform your cleanup and
> return null to the caller. And whenever you store an item you tag on this
> timestamp and set the actual expiry to sometime far in the future. However,
> note that you may not always get back items and your cleanup may not run for
> all items.
>
> Perhaps if you told us what you wanted to achieve with your application we
> could help you do it properly with memcached or point you in the direction
> of other technologies if memcached is the wrong one for the job?
>
> /Henrik Schröder
>