Questions tagged [flask-cache]
75 questions
1
vote
1 answer
Storing a calculation in a flask route cache
I have a long task that goes off into a python-rq worker queue.
@cache.cached(timeout=2592000)
@app.route('/as/', methods=['GET'])
@db_session
def auto_suggest(keyword):
job = q.enqueue(find_keyword, keyword)
while not job:
…

nadermx
- 2,596
- 7
- 31
- 66
1
vote
1 answer
Check if user is anonymous for Flask-Cache `unless` argument
I am trying to cache a view unless the user is logged in. current_user only works inside a view though, so I'm having trouble passing it to unless=. How do I do this correctly?
@app.route("/")
@app.cache.cached(timeout=300,…

nadermx
- 2,596
- 7
- 31
- 66
1
vote
1 answer
flask: How to store and retrieve POST calls?
@app.route('/path//', methods=['POST'])
@cache.cached(key_prefix='/path/', unless=True)
def post_kv(user, id):
cache.set(user, id)
return value
@app.route('/path/',…

dispepsi
- 270
- 3
- 15
1
vote
0 answers
How to configure a fallback CACHE_TYPE in flask-cache?
I am having great speed up using flask-cache configured to work with a redis-server instance. However, if the redis-server becomes unavailable I get an error message:
redis.exceptions.ConnectionError
ConnectionError: Error 111 connecting to…

Paolinux
- 167
- 1
- 8
1
vote
1 answer
Can we specify parameters for unless function in cached function(in Flask-Cache)
From Flask-Cache Documentation, cached function takes following parameters - timeout,key_prefix, unless. Unless is descibed as
unless – Default None. Cache will always execute the caching
facilities unless this callable is true. This will bypass…

a.m.
- 2,083
- 1
- 16
- 22
1
vote
1 answer
Import Error With Heroku
My requirements.txt file does not seem to be working
One of the lines in my file states:
Flask-Cache==0.12
However, I am getting the following error why I try to use Flask-Cache:
ImportError: No module named flask.ext.cache
Any ideas on how to fix…

GangstaGraham
- 8,865
- 12
- 42
- 60
0
votes
0 answers
Flask cache with redis
I need to cache the modules using Redis and each module cache data need to be in separate hash table. Let me say, I have 2 modules:
employee
company
Now the API's related to employee module need to be cached in the hash table employee. For…

Vyshnavi
- 149
- 2
- 10
0
votes
0 answers
why cant i run this script? it is supposed to stream pixels to a roblox screen
--?
from flask_caching import Cache
from waitress import serve
from PIL import Image
from mss import mss
from math import sqrt
import threading
import time
import sys
WORDLIST = {sys.intern(w.upper()) for w in "wordlist"}
def color_distance(c1,…
0
votes
0 answers
When using Redis backed cache in a Flask application, is the cached data thread safe?
I have the following scenario:
I have multiple instances of a Flask application behind a load balancer serving an API for a front end web client. This flask application interfaces with a database to query and insert data.
Under certain conditions,…

joelghill
- 3
- 5
0
votes
1 answer
`Flask` cache is ignoring parameters and returning same response
Been playing with caching in Flask for a few hours, but I keep running into an issue that I cannot seem to resolve. I have a route that takes any number of parameters, none of which are defined, (i.e. def get_data()). The parameters are then passed…

codeweird
- 145
- 3
- 11
0
votes
0 answers
How to generate multiple file caches for different parameters of a single route?
I used the officially recommended flask-caching lib for cache my api results.
I currently have a problem with the following routing request.
# cache config part
cache = Cache(config={
'DEBUG': True if os.environ.get('FLASK_ENV') == 'development'…

Goo
- 68
- 9
0
votes
0 answers
How can I update cache rows within the flask-cache (FileSystemCache)
I am using flask-cache (FileSystemCache)to store an entire table worth of data (to prevent constant database IO)
This works great, and really speeds up the reading of the records, but my app also allows users to "update rows" in the database.
I am…

Calamari
- 29
- 1
- 9
0
votes
0 answers
Flask-Cache not caching objects attributes properly
I'm trying to cache and retrieve an object using the cache.set() and cache.get() methods, but I'm having some trouble getting it to work properly. I use the .set() method to cache an object (obj1) that has another object (obj2) as its attribute.…

Boe
- 17
- 4
0
votes
1 answer
How to use flask-cache on a route with parameter
I have a flask app that retrieves data from a database. I would like to cache this data so I am not constantly requesting data from the database.
Currently I am using flask_caching and it is working, but ONLY for the individual document I…

Calamari
- 29
- 1
- 9
0
votes
0 answers
Flask-Cache memory usage when getting several get requests with multiprocessing=True
Imagine the following scenario:
from flask.ext.cache import Cache
@cache.memoize
def my_cached_func():
x = load_some_big_csv()
return x
@app.route('')
def index():
get_maybe_cached = my_cached_func()
return…

zacko
- 179
- 2
- 9