cacheout icon indicating copy to clipboard operation
cacheout copied to clipboard

Update expire time for specific entrys

Open onebula opened this issue 4 years ago • 2 comments

What I need is to add expire time for specific keys. Currently cacheout provides api "set" to create new entry or update existing entry. So a simple way is:

v = cache.get(k, None)
if v is not None:
    cache.set(k, v, ttl=100)
else:
    raise KeyError(k)

Will you consider to provide apis like "expire" in Redis to update expire time directly?

onebula avatar Sep 27 '21 06:09 onebula

Having redis "expire" functionality would be fine to add. Were there other "expire" functions you had in mind?

dgilland avatar Sep 27 '21 21:09 dgilland

The expire function should support update expire time when ttl is specified, and also support to move the key to the end of the cache stack when ttl is not specified, which means it would be evicted last. Since similar method like "evict", "expired", "expire_times" are already named, I suggest to use name "update".

onebula avatar Sep 28 '21 02:09 onebula