How to set & reset timeout for data?
mr-py-007 opened this issue · 5 comments
I am just curious to know how I can set and reset timeout for data.
For example, I want to set timeout to 15 minutes so after 15 minutes the data will be wiped out automatically.
I tried to find that in documentation but not able to figure out looking at the code or docs.
For example, something like following.
hash_client.set(key, value, timeout=90000)
...
hash_client.reset(key, timeout=90000)
@mr-py-007
You're looking for the touch memcache command.
It's implemented in both the base- and hash- client.
Give it a key
and an expire
argument and it will reset the key if it exists.
expire
is the name of the timeout argument you're describing in your original question.
set(self, key, value, expire=0, noreply=None, flags=None)
From https://github.com/pinterest/pymemcache/blob/master/pymemcache/client/base.py#L440