Questions tagged [flask-cache]
75 questions
5
votes
1 answer
How can I cache/memoize my SQLAlchemy functions?
I am using FLask-OAuthlib and want to do some caching/memoization using Flask-Cache. I've got caching setup on my views but I'm having trouble with caching this function:
@oauth.clientgetter
@cache.memoize(timeout=86400)
def load_client(client_id):
…

user3287829
- 1,384
- 2
- 18
- 23
4
votes
0 answers
Cache SQLAlchemy query or render in Flask-Cache for different users
I have an app which saves last search of user via Cookies, then I have a search view that I'd like to cache.
I cannot memoize the query result as there are some weird objects like db.session which cannot be understood by pickle, which Flask-Cache…

Laurent Meyer
- 2,766
- 3
- 33
- 57
4
votes
1 answer
Use Flask-Cache to cache result of non-view function
I want to use Flask-Cache to cache the result of a function that's not a view. However, it only seems to work if I decorate a view function. Can Flask-Cache be used to cache "normal" functions?
Caching works if I decorate a view function.
cache =…

WebQube
- 8,510
- 12
- 51
- 93
4
votes
1 answer
Flask - caching result of data load
I'm writing a server-side application in flask / python and have an issue with some data that has to be loaded for calculation. Loading the data (about 40 MB) takes much longer that processing the server response, and the data never changes, so I…

Kirk Schwenkler
- 68
- 1
- 5
3
votes
0 answers
flask-cache TypeError: can't pickle CompiledFFI objects
i am using pysaml2 library in python. which has a method defined as below:
def _store_request(self, saml_msg):
key = sha1(saml_msg["SAMLRequest"]).hexdigest()
IDP.ticket[key] = saml_msg
return key
where, IDP.ticket = {} is an…

anekix
- 2,393
- 2
- 30
- 57
3
votes
1 answer
flask_cache and memoize - make_cache_key error: object of type 'NoneType' has no len()
I'm kind of new to using flask, and I want to cache the result of a function that reads pickled data. I use memoize function from flask_cache as follows:
in model_chacher.py:
from flask_cache import Cache
import pickle
model_cache =…

Ho'jat Kaveh
- 123
- 1
- 8
3
votes
1 answer
Update Flask-Cache from scheduler and user request
I am trying to cache the result of a time consuming request.
First I have a flask template as follow :
@app.route("/")
@app.route("/tabs", methods=['GET','POST'])
def tab():
return render_template("tabs.html")
@app.route("/graph",…

Charles
- 31
- 3
3
votes
1 answer
How do I work with cached values created by flask-cache
I'm using flask-cache in an app and trying to prepopulate the cache in a separate process. The problem is I can't figure out the format the cached values are stored in.
Looking at the cached values they look like they've been pickled, but the values…

daveruinseverything
- 4,775
- 28
- 40
3
votes
1 answer
How to invalidate or delete a redis cache object if an error in Flask view
I am facing an issue where I am using the Flask cache module and in the case I have a runtime error I don't want the view cached.
Can anyone advise how to do this?
Here is what I would like to achieve.
from flask import Flask
from…

Andrew
- 742
- 8
- 21
2
votes
1 answer
Flask-Caching call back event when key delete automatically
I have one java app and flask app the java app will send some value to the flask app that I need to save it in the cache so I am using flask-caching and I am having some default time out in the flask caching.
The problem is once a key is deleted…

Ragul M B
- 204
- 3
- 9
2
votes
0 answers
How to set number of hits of a url to get cached in Flask-Cache?
Flask-cache by default stores the second request if it comes within given time-period. It won't maintain the first request.
For reference, I checked with nginix, nginix saves the fifth request. I got a argument maintaining the same…

Ashutosh
- 66
- 6
2
votes
1 answer
How to set up Superset config for caching
Right now, I am working on Airbnb Superset project for working purpose.
I know Superset supports cache (by Flask-Cache), but I got stuck when I set up the configuration.
My config.py file looks like this:
CACHE_DEFAULT_TIMEOUT = 60 * 60 * 24
…

Luo Ding
- 21
- 1
- 3
2
votes
1 answer
importing variable from main file to class variable
I have two files. One is a main python file. I am using flask where I am initializing a variable called cache using flask cache
from flask import *
from flask_compress import Compress
from flask_cors import CORS
from local_service_config import…

kar
- 198
- 1
- 8
2
votes
1 answer
flask-cache memcache connection auto-reconnect
I've recently moved my memcache server behind an Elastic Load Balancer in AWS. I'm also using Flask-Cache with this memcache. If I'm not mistaken (and it's totally possible I am), Flask-Cache opens a connection to memcache and holds it open. It also…

Hoopes
- 3,943
- 4
- 44
- 60
2
votes
1 answer
Flask-Cache doesn't distinguish between GET and POST
I have a Flask route structured like so:
@app.route('/rootpath1/')
@app.route('/rootpath2/', methods=['GET', 'POST'])
@cache.cached()
def rootpath():
...
POSTs to '/rootpath2/' for a given page are typically retrieved from…

user2487593
- 53
- 7