aiocache icon indicating copy to clipboard operation
aiocache copied to clipboard

Cache expiration callback/event

Open jmmaa opened this issue 3 years ago • 1 comments

Is it possible to implement cache expiration events on this lib? If it is can I have an example?

jmmaa avatar Feb 19 '22 02:02 jmmaa

Do you mean a callback when a cached item expires?

If so, I think that would depend entirely on the backend. e.g. The SimpleMemoryBackend just schedules a function call later (https://github.com/aio-libs/aiocache/blob/master/aiocache/backends/memory.py#L37). So, by subclassing it, you could figure out a way to get a notification. But, if you use a memcached backend, then the expiration happens in memcached, so you'd need to figure out a way to get the information from there.

Dreamsorcerer avatar Feb 19 '22 13:02 Dreamsorcerer