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

check if a specific cache exists with a custom cache key and extra #410

Open
fcoppey opened this issue Sep 9, 2021 · 6 comments
Open

check if a specific cache exists with a custom cache key and extra #410

fcoppey opened this issue Sep 9, 2021 · 6 comments

Comments

@fcoppey
Copy link

fcoppey commented Sep 9, 2021

I would like to implement two different ways of loading my data if it was already cached or not.
if it's not cached I will load it by Ajax at page load, and then once it cached I would like to load it directly from the view context. how can I test if such cache exist with this caching settings:

@cached_as(obj, extra=['sample_detail_plot', user])

@Suor
Copy link
Owner

Suor commented Sep 10, 2021

There is no public API for this. You may follow the same calculations as @cached_as() does though.

@fcoppey
Copy link
Author

fcoppey commented Sep 10, 2021 via email

@Suor
Copy link
Owner

Suor commented Sep 10, 2021

Basically all the code here, cache_key is the key in redis. That is quite complicated though.

@fcoppey
Copy link
Author

fcoppey commented Sep 10, 2021 via email

@Suor
Copy link
Owner

Suor commented Sep 10, 2021

@cached from simple cache has a special .key(), which allows to see and do things like that. Maybe I should add it to @cached_as() in some form. Not sure yet.

@fcoppey
Copy link
Author

fcoppey commented Sep 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants