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

On Sun, Aug 23, 2009 at 17:57, ron <[email protected]> wrote:

>
> thanks.
>
> So can memcached at least return an expiring object for the last time
> to my application, with a flag set saying that it has expired in
> memecached and the next time you request the object it will return
> null?
> Doing this will give me a chance to do my other application clean up
> which needs the data in that expiring cache object.
>
> On Aug 23, 8:34 am, Brian Moon <[email protected]> wrote:
> > 1. No, memcached does not do that.
> >
> > 2. You don't want it to.
> http://code.google.com/p/memcached/wiki/FAQ#When_do_expired_cached_it...
> > 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/
> >
> > On 8/23/09 12:03 AM, ron wrote:
> >
> >
> >
> > > Hi,
> >
> > > Can memached trigger some kind of event to notify client that a
> > > particular cached object is expired??
> >
> > > If it doesn't support, does anyone know what other technology out
> > > there there is also a distributed cache but also it can send out
> > > events when an object is about to expired??
> >
> > > thx.
> > > Ron
>

Reply via email to