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

How to cache some data explicitly ? #58

Closed
kavink opened this issue Feb 23, 2018 · 2 comments
Closed

How to cache some data explicitly ? #58

kavink opened this issue Feb 23, 2018 · 2 comments

Comments

@kavink
Copy link

kavink commented Feb 23, 2018

After I read some big json file from somewhere, I want to make that internally available by my app to work on it, Or when user queries it to return from cache, I can use @cache.memoize() on get function for user to use and for my app to use, But there is a one time hit of getting the json from my DB.

As I am populating that data myself, is it possible to populate that in cache explicitly so my app just uses that ?

@sh4nks
Copy link
Collaborator

sh4nks commented Mar 15, 2018

Not sure if I understood you correctly, but you could use these functions to modify the cache 'directly'.

@robertlagrant
Copy link

robertlagrant commented May 8, 2018

@sh4nks I've the same question - it's not immediately clear how to access the cache directly from any place in the Flask application.
For example, the following doesn't work (not that it should; I'm just trying to figure out how to use it!):

from flask import current_app


def set_default_cache_value_in_helper_file():
    with current_app.app_context():
        current_app.cache.set("some_key", "some_value")

sh4nks added a commit that referenced this issue Mar 5, 2019
@sh4nks sh4nks closed this as completed in 49e14e4 Mar 6, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants