Hi Guys,

I recently checked the documentation about the memcached protocol and
while looking at supporting it in my C++ client, I'm looking at a
situation where I'm not sure whether it's possible to set the
expiration of a key through the incr/decr commands. From the
documentation, it seems that there's only a way to increment and
decrement, but not set the expiration of the key being
incremented/decremented.

Is this by design? Should I file for a feature request for an
incr/decr that also updates the expiration of a cache key?

This feature would be really useful for tracking keys -- maybe
tracking activity within a certain period of time. So something like
this algorithm would be easily supported:

  1. The first time something happens, set a key to 0 in memcached,
expires in X seconds
  2. The next time something happens, increment the key (update the
expiration to X seconds) -- if the increment fails, that means the key
has expired, set the key to 0 again
  3. If the incremented value is higher than a certain number, then
you can do something about it (maybe there's abusive behaviour going
on, maybe a clicker bot or something)

Any ideas on how this could be supported by the current protocol? If
not, do you have alternatives?

Help would be most definitely appreciated.

(BTW, should I file this as a feature request?)

-- 
Dean Michael Berris
blog.cplusplus-soup.com | twitter.com/mikhailberis
linkedin.com/in/mikhailberis | facebook.com/dean.berris | deanberris.com

Reply via email to