You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the discussion in #11 and the improvement done in #63, where custom serializers were added for each cache backend. I think that it would be very nice to have a few generic serializers (Pickle, JSON, etc) that could be passed as a parameter when initialising the cache backends.
Something that would look like:
from cachelib import FileSystemCache, RedisCache
from cachelib.serializers import JsonSerializer, PickleSerializer
redis_cache = RedisCache(serializer=JsonSerializer)
file_cache = FileSystemCache(serializer=PickleSerializer)
Each backend cache would obviously have a default serializer for backwards compatibility.
This would allow using more secure serialization alternatives than Pickle.
The ultimate goal that I would like to achieve would be to be able to use a custom serializer with the Flask-Caching library.
I could try to work out a solution for this and submit a PR if you think this approach would make sense.
The text was updated successfully, but these errors were encountered:
Hey @g-abello, thanks for considering contributing to cachelib!
Our architecture currently allows users to use their own serializers by just inhering from cache classes and overriding the serializer class variable, so it's already not only possible to use alternatives safer than pickle (which is currently our default serializer for all cache types) but also further customize the behavior of cache classes.
From my understanding, not considering what we already have, what you propose would bring:
New generic serializers
Allow integration with flask-caching.
On 1: Interesting to have for the most common use cases like JSON, so I would be more than willing to review a PR for that.
On 2: How does our current architecture makes it harder to use custom serializers with flask-caching? Why would it be better to pass serializers as initialization parameters? It would be great if you could elaborate a little bit on that
OK, so maybe I'm missing some information here (in that case, please tell me! 😄 ), and this might be a question more related to flask-caching than to cachelib really, but in flask-caching you can pick the backend that you want to use very easily by using the config, like:
What I'm suggesting is to be able to do the same with the serialiser:
config = {
...
"CACHE_SERIALIZER": "JSON",
...
}
That's why I think that having generic serializers and being able to pass them when initialising the cache classes would help in order to achieve that.
Does that make sense? Or is there any other way to achieve that right now?
@g-abello Fair enough. I think we could go for a initial implementation and further discuss it from there (if necessary). When you find the time, feel free to go for it. I will be happy to help as I can, just reach out 👍🏻
Following the discussion in #11 and the improvement done in #63, where custom serializers were added for each cache backend. I think that it would be very nice to have a few generic serializers (Pickle, JSON, etc) that could be passed as a parameter when initialising the cache backends.
Something that would look like:
Each backend cache would obviously have a default serializer for backwards compatibility.
This would allow using more secure serialization alternatives than Pickle.
The ultimate goal that I would like to achieve would be to be able to use a custom serializer with the Flask-Caching library.
I could try to work out a solution for this and submit a PR if you think this approach would make sense.
The text was updated successfully, but these errors were encountered: