Questions tagged [flask-cache]
75 questions
0
votes
1 answer
List all the cached keys in Flask Cache
I have written an appliacation using Flask, and am caching the response of various api calls.
following is the configuration of my flask app
from flask import Flask
from flask_caching import Cache
app = Flask(__name__)
APICache =…

phileinSophos
- 362
- 4
- 22
0
votes
1 answer
Flask cache some data but not all
I have a function that I am trying to calculate the run time duration.
when I use the Flask cache, it won't go into the function and won't calculate the duration.
@app.route('/', methods=['get'])
@cache.cached(timeout=60)
def…

Alon Barad
- 1,491
- 1
- 13
- 26
0
votes
0 answers
KeyError in flask
I am getting an error while opening a page in browser created using flask.
I think the error is in using get_cache. I tried to solve this error but could not get the exact solution. I had imported cache using from flask_caching import Cache.The code…

user9538110
- 29
- 6
0
votes
1 answer
Python Flask executing old function even after updating it
I am new to using Flask. I have written basic Flask code for Hello World but after updating function I am still seeing old value on the web page. From what I read on other posts and blogs, this might be Cache problem. But I am not sure how to clear…

Nikhil Redij
- 1,011
- 1
- 14
- 21
0
votes
1 answer
Caching a function in flask
I have this code that executes for around 9.2 secs locally on my machine.
After deploying it to an AWS ec2 box the execution time raised up to 20secs.
Since I haven't implemented any caching before, I am wondering am I able to cache the response…

Mario
- 25
- 1
- 8
0
votes
1 answer
Setting Flask-Cache memoization value
If I have a function with the @cache.memoized decorator, is it possible to add a key-value pair to its caching without calling the function?

raphaelrk
- 757
- 10
- 17
0
votes
1 answer
Advice in caching for python
I am using Flask- Restful for a Python API, which is working well.
Now, there are few DB operations which I want to cache, how do I go about that? I have searched online and there were a couple of options like flask cache and CacheTools and I am…

xmen
- 9
- 1
- 6
0
votes
1 answer
flask cache delete_many error
I'm not good at flask and a naturally django developer I was forced to because it is already developed..
May question is how to use delete_many using flask-cache
cache.delete_many(["sample_4", "sample_5"])
This returns an error:
TypeError: cannot…

Dean Christian Armada
- 6,724
- 9
- 67
- 116
0
votes
1 answer
Flask-cache generate different keys for int and long parameters
Flask-cache use function parameters to generate cache key, however it makes different keys for long and int type parameters:
@cache.memoize(3600)
def foo(a):
return a
foo(1) and foo(1L) will generate different cache keys, what could I do to…

Lishubing
- 3
- 1
0
votes
1 answer
Route times out so memoize does not work
I have the current route
@app.route('/as/', methods=['GET'])
@cache.memoize(timeout = 30 * 24 * 60 * 60)
def auto_suggest(keyword):
job = q.enqueue(find_keyword, keyword, timeout = 60 * 60)
while not job.result:
…

nadermx
- 2,596
- 7
- 31
- 66
0
votes
1 answer
control flask-cache'ing from a view
I am wondering if there is a way to allow the user to control the caching properties of a given view using Flask-Cache.
For example, I would like for a view to be cached indefinitely unless the user clicks a reload link, in which case the view…

alex
- 2,968
- 3
- 23
- 25
0
votes
1 answer
make unittest to test the caching status of several routes
I am trying to write a unittest for a couple of routes. The data manipulation is fairly intensive and making the server CPU bound, and the retrieval of new data is fairly infrequent. As such, I used flask cache to @cache.memoize the more intensive…

corvid
- 10,733
- 11
- 61
- 130
0
votes
1 answer
How to give key_prefix, variable values while caching in Flask-Cache
We can cache any view/non-view function as
@cache.cached(timeout=50, key_prefix='all_comments')
Can we give key_prefix some variable values. Let say, I'm caching a function as
@cache.cached(timeout=50, key_prefix=value)
def…

a.m.
- 2,083
- 1
- 16
- 22
-2
votes
1 answer
Call method once when Flask app started despite many Gunicorn workers
I have a simple Flask app that starts with Gunicorn which has 4 workers.
I want to clear and warmup cache when server restarted. But when I do this inside create_app() method it is executing 4 times.
def create_app(test_config=None):
app =…

wowkin2
- 5,895
- 5
- 23
- 66