Questions tagged [flask-cache]
75 questions
72
votes
5 answers
flask does not see change in .js file
I made a change on one of the .js files that I use and no matter what I do, flask insists on picking up, from memory cache, the last version of the file, without the change.
To clarify, I have the following structure. It all starts with…

elelias
- 4,552
- 5
- 30
- 45
28
votes
2 answers
How to cache SQL Alchemy calls with Flask-Cache and Redis?
I have a Flask app that takes parameters from a web form, queries a DB with SQL Alchemy and returns Jinja-generated HTML showing a table with the results. I want to cache the calls to the DB. I looked into Redis (Using redis as an LRU cache for…

bernie2436
- 22,841
- 49
- 151
- 244
25
votes
6 answers
How to use Flask-Cache with Flask-Restful
How do I use Flask-Cache @cache.cached() decorator with Flask-Restful? For example, I have a class Foo inherited from Resource, and Foo has get, post, put, and delete methods.
How can I can invalidate cached results after a…

cyberra
- 579
- 1
- 6
- 14
17
votes
1 answer
How to disable Flask-Cache caching
I meet a problem while using Flask-Cache. I need to make caching on need basis, by defining a configuration variable which user can set for enable or disable caching.
I'm using Flask-Cache for caching purposes, as
cache = Cache(config={'CACHE_TYPE':…

a.m.
- 2,083
- 1
- 16
- 22
13
votes
2 answers
How can I configure Flask-Cache with infinite timeout
In the Flask-Cache documentation all the examples use a finite timeout.
I'd like to never refresh the cache while the app is running. Is this possible, and if so how do I do it?

iwein
- 25,788
- 10
- 70
- 111
12
votes
1 answer
Flask Cache not caching
I followed a tutorial of Flask-Cache and tried to implement it myself.
Given the following example, why would Flask not cache the time?
from flask import Flask
import time
app = Flask(__name__)
cache = Cache(config={'CACHE_TYPE':…

Frame91
- 3,670
- 8
- 45
- 89
12
votes
1 answer
AWS Elasticache - increase memcached item size limit
Im using the memcached module on AWS Elasticache in my python Flask app (with Flask-Cache)
When i try to set a file that is less than 1MB i need to repeatedly access to the cache, i have no issues. But when the file size increases more than a MB…

Shankar ARUL
- 12,642
- 11
- 68
- 69
10
votes
3 answers
Flask Celery task locking
I am using Flask with Celery and I am trying to lock a specific task so that it can only be run one at a time. In the celery docs it gives a example of doing this Celery docs, Ensuring a task is only executed one at a time. This example that was…

Max Powers
- 1,119
- 4
- 23
- 54
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
8
votes
1 answer
Caching Flask-Login user_loader
I had this.
@login_manager.user_loader
def load_user(id=None):
return User.query.get(id)
It was working fine until I introduced Flask-Principal.
@identity_loaded.connect_via(app)
def on_identity_loaded(sender, identity):
# Set the…

lustdante
- 483
- 4
- 14
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
7
votes
0 answers
Flask/SqlAlchemy, Flask-Cache, Celery and InvalidRequestError: Instance '<...>' is not persistent within this Session
I am scratching my head on this one.
I have a Flask App w/ Flask-Cache and SqlAlchemy:
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+pg8000://[Redacted]
cache = Cache(app, config={'CACHE_TYPE':'redis',…

Patches
- 1,423
- 2
- 12
- 11
6
votes
4 answers
Flask cache memoize not working with flask restful resources
flask_cache.Cache.memoize not working with flask_restful.Resource
Here is sample code:
from flask import Flask, request, jsonify
from flask_restful import Resource, Api
from flask_cache import Cache
app = Flask(__name__)
api = Api(app)
cache =…

Rugnar
- 2,894
- 3
- 25
- 29
6
votes
2 answers
flask cache: list keys based on a pattern?
I'm using the Flask Cache plugin with Redis as backend to cache my API response. Say I have APIs to get users and create user like this:
/api/users?page=1 GET
/api/users POST
The GET result will be cached with full URL as key. When a new…

lang2
- 11,433
- 18
- 83
- 133
6
votes
1 answer
Storing simple key value pairs with Flask Cache and memcached
How can I store simple key value pairs with Flask Cache? Something like this:
cache.set('key', 'some value')
cache.get('key')
Now I only store a function's return value using the cache.cached() decorator. That method seams to work, but I don't know…

KRTac
- 2,767
- 4
- 22
- 18