-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Hi all!
This is maybe more a feature suggestion than an actual issue, please bear with me and I'll explain my case.
Since werkzeug cache is now deprecated and refactored to a separate library (cachelib) I have started using the RedisCache from that library instead of configuring it through werkzeug internals the way that jobtastic is currently expecting.
So far so good; I figured out the WrappedCache class and how to use that together with cachelib RedisCache and at first glance all is working.
Now here's my issue: I want to have cached results that never expire in Redis.
To achieve that with cachelib RedisCache one would send a TTL of -1 but in jobtastic however a TTL of -1 means "don't cache anything at all, ever" and hence nothing happens.
https://github.com/PolicyStat/jobtastic/blob/master/jobtastic/task.py#L353
https://github.com/pallets/cachelib/blob/master/cachelib/redis.py#L95
I get that we can't just change this magic value in jobtastic to mean the complete opposite of what it means today for backwards compatibility reasons but I guess the same could also be said about cachelib...
One solution I could imagine happening in jobtastic would be moving the "what does a TTL of -1 mean?"-logic out from the middle of run() and instead deal with it in it's own function that we somehow could override in base classes and change.
Maybe just like a "determine_ttl()" or perhaps a larger "dispatch_set()" function to optionally override with slightly more responsibilities.
Preferably for future compatibility purposes I also don't want to override the entire run()-function in my project to achieve this fairly tiny change in logic.
Another option I guess would be to have a config value of sorts in jobtastic to determine if -1 should mean never or always?
Do you have any thoughts on this?