Replies: 4 comments 2 replies
-
You could implement a wrapper around the cache object that handles that for you and then use the wrapped cache object to retrieve and set the values. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. You mean wrap |
Beta Was this translation helpful? Give feedback.
-
I haven't thought about wrapping the decorators but I guess that would work as well. I thought about wrapping the |
Beta Was this translation helpful? Give feedback.
-
"Is it possible to compress values before storing them in the cache (and decompressing them on retrieval)? If not, would there be an appropriate place to add a hook for this?" I would like to have that option for the FileSystemCache backend. I need to cache big dictionaries with a lot of text returned by Elasticsearch backend, sometimes the cached files have few MB size. I thought something simple like replacing open(filename... with gzip.open(filename... in the FS cache class might do the trick but with no success so far... I use both memoize decorator and not so often set/get methods. Would you be so kind and provide some hints how to achieve that ? Or maybe this is not going to help to do faster responses at all... |
Beta Was this translation helpful? Give feedback.
-
Is it possible to compress values before storing them in the cache (and decompressing them on retrieval)? If not, would there be an appropriate place to add a hook for this?
I'm trying Flask-Caching with a redis deployment, and it looks like a significant amount of memory could be saved by compressing the cached values, and uncompressing them when retrieved from the cache.
Performing the compression in the body of the function is not appropriate, since other parts of the web app would require un-compressed values to be returned by the relevant functions.
Thanks for a great library!
Beta Was this translation helpful? Give feedback.
All reactions