Questions tagged [flask-caching]
52 questions
8
votes
2 answers
Delete specific cache in Flask-Cache or Flask-Caching
I am using Flask cache in my API in python.
Currently I am using the decorator @app.cache.memoize(cache_memoize_value) and I flush it by calling app.cache.delete_memoized(view)
The problem is that with memoize it will be cached for n views and not…

Cramix
- 91
- 1
- 2
- 9
7
votes
1 answer
Flask-Caching use UWSGI cache with NGINX
The UWSGI is connected to the flask app per UNIX-Socket:
NGINX (LISTEN TO PORT 80) <-> UWSGI (LISTER PER UNIX-SOCKER) <-> FLASK-APP
I have initalized a uwsgi cache to handle global data.
I want to handle the cache with python package…

Ewro
- 447
- 4
- 13
5
votes
3 answers
How to cache a variable with Flask?
I am building a web form using Flask and would like the user to be able to enter multiple entries, and give them the opportunity to regret an entry with an undo button, before sending the data to the database. I am trying to use Flask-Caching but…

Nelumbo
- 893
- 2
- 9
- 18
5
votes
1 answer
Flask cache set method throwing KeyError?
In order to cache some data, I am calling cache.set method. However it is throwing KeyError. The error log:
File "D:\Sample_Project\SomeRouter.py", line 176, in run
FetchFeed._prepareCache(f_content, cache, _program, _sprint)
File…

TheLittleNaruto
- 8,325
- 4
- 54
- 73
5
votes
1 answer
How/where does Flask-Caching store data?
I just wonder how and where the response is stored when using Flask-Caching.
For example:
from flask import Flask, request
from flask_caching import Cache
import datetime
app = Flask(__name__)
cache = Cache(app, config={'CACHE_TYPE':…

Wang Nick
- 385
- 1
- 6
- 17
3
votes
1 answer
Mock redis for writing unittest for application
I have a flask application, in which I use "flask-caching" with redis. I save some values in the cache and retrieve it for processing. I have to write unittest for this. How can I mock the redis instance and pass the host for that server in the…

Simplecode
- 559
- 7
- 19
3
votes
1 answer
caching.memoize & response_filter for internal server errors
I am using flask_caching to cache responses of my flask API. I am using the decorator on my routes like this
import random
class Status(Resource):
@cache.memoize(timeout=60) # cache for a minute
def post(self):
return random.randint(0,…

c8999c 3f964f64
- 1,430
- 1
- 12
- 25
3
votes
1 answer
Flask cache gives me 'AttributeError: 'Cache' object has no attribute 'app''
I am using application factory pattern in which I have initialized my cache
from xyz.caching import cache # this is the cache object
def create_app():
app = Flask(__name__)
cache.init_app(app)
# other relevant variables.
return app
My…

Simplecode
- 559
- 7
- 19
2
votes
0 answers
Should I store a dataframe in Flask cache or session?
My flask app pulls user data from an external API and does a small amount of processing and generates a dataframe. Although not really heavy there is a noticeable delay in loading the data onto a page. This same data is used by several pages on…

MartynW
- 641
- 2
- 7
- 23
2
votes
1 answer
circular import with flask_restful and flask_caching
I have been using flask_restful for a while in my project because I like separating my resources into different files for basic organization. Now I would like to add flask_caching and I ran into a (simple?) circular import issue
my project structure…

c8999c 3f964f64
- 1,430
- 1
- 12
- 25
2
votes
1 answer
Flask-Caching FileSystemCache method does not delete cache items upon timeout
I have a Flask app, and I have implemented the "Flask-Caching" extension. I am using the "FileSystemCache" method. This is all new to me so it may be working properly and I'm unaware.
I have found that when I call cache.clear(), I will see items…

sprmap
- 71
- 1
- 6
1
vote
0 answers
flask_caching.memoize() not working with dash background_callback_manager
Python dash/flask app with working memoization on non-callback functions. However, when I introduce a background_callback_manager the memoization fails between calls. i.e., if a callback will call a memoized function twice, it will successfully use…

doyle
- 53
- 1
- 4
1
vote
0 answers
How to use use flask-caching decorator @cache on an external module class
Context:
I have flask application, which is an NGINX authentication module, written in flask, and in some part of the code I am making a call to an LDAP server.
The objective is to use flask-caching library to cache the response from the LDAP server…

Mariano Billinghurst
- 57
- 5
1
vote
0 answers
Delete all related to variable in function using delete_memoized of Flask-Caching
I have some functions like the one below:
@cache.memoize(timeout=18000)
def getAllHave(user_id, i,
currency = "USD")
Parameters currency and i can have a huge amount of values.
I would like to delete all cache from function getAllHave…

Dinidiniz
- 771
- 9
- 15
1
vote
1 answer
Memoization Python Dash: TypeError: expected str, bytes or os.PathLike object, not Flask
I am developping a website with Python Dash and I am trying to implement caching, to speed up the performance of the website. I want to use memoization for this purpose, as suggested on the Dash website: https://dash.plotly.com/performance. On the…

willemlzn
- 13
- 1
- 4