Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't clear Redis by key if a prefix has been set #451

Open
dkudeki opened this issue Oct 25, 2024 · 0 comments · May be fixed by #529
Open

Can't clear Redis by key if a prefix has been set #451

dkudeki opened this issue Oct 25, 2024 · 0 comments · May be fixed by #529
Labels
bug Something isn't working needs-triage Needs to be reviewed

Comments

@dkudeki
Copy link

dkudeki commented Oct 25, 2024

Hi, I ran into an issue where any calls to FastAPICache.clear(key="value") would not work for any given value passed to key. It turns out that even if you don't pass a namespace to the clear function, if you have initialized the connection with a prefix, that prefix is then used to create a namespace:

namespace = cls._prefix + (":" + namespace if namespace else "")

That namespace is then passed along with the key to the Redis clear function, where it supersedes the key that you explicitly are trying to clear, and the clear function is run on the prefix-generated namespace instead.

For my purposes it was simple enough to just drop the prefix altogether, but logically initializing the connection with a prefix shouldn't render clearing by key unusable like it is now.

@vicchi vicchi added bug Something isn't working needs-triage Needs to be reviewed labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Needs to be reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants