cache.delete(expired=True) fails on Redis, succeeds on sqlite
#1123
-
|
Hello. I have upgraded a working system to requests-cache 1.2.1. The dev-environment uses sqlite for ease of use. All good. Now I deployed the code to production, which uses Redis. Imagine my surprise when it told me, this: For troubleshooting I set the cache-backend to sqlite and the error was gone. I am super stumped. Any ideas on what to check next? The code that triggers this behavior:
or this (throwing error on prod): Thanks again. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
As far as I remember, Redis supports expiration by TTL, so |
Beta Was this translation helpful? Give feedback.
-
|
You're both correct; native TTL is generally the better method of cache cleanup for Redis, but the method signature is supposed to be the same for all backends. I'm not able to reproduce this locally, and this works on both v1.2.1 and main: from requests_cache import CachedSession
p = {
'backend' : 'redis', # type of the database
'cache_name' : 'serinto.requests_cache',
'expire_after' : 600, # seconds
'allowable_codes' : (200,), # only responses with these status-codes can be cached
'allowable_methods' : ('GET',), # only responses from these methods can be cached
}
session = CachedSession(**p)
session.cache.delete(expired=True)And the automated tests run for all backends would have caught it if not. Is it possible the prod environment is running an older version of requests-cache? |
Beta Was this translation helpful? Give feedback.
Thanks everyone for looking into this. I was trying to gather more data, but the behavior is gone. No clue what that was. Restoring it to it's original fault state (with git and re-installing older libs) did not return the error.
If I had not had the copy of the error-message, I'd blame it on me going crazy ¯_(ツ)_/¯
Thanks again for the discussion, as well as your whole software package and all the work that goes into it.