Questions tagged [flask-caching]
52 questions
0
votes
0 answers
Flask-Caching on REST API, caching and deleting by user / pagination
I'm using Flask-Caching on a REST API.
Flask-Caching uses key request.path by default, but I want to cache by path, user ID, and URL parameters.
I've did something horrible like this:
def custom_cache_key(params=None, user=None, path=None):
if…

Cagri
- 366
- 1
- 6
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
1 answer
How to unit-test a Flask-Caching memoized function?
I'm using:
Python 3.9.13
pytest==7.2.0
pytest-mock==3.10.0
Flask==2.2.2
Flask-Caching==2.0.1
This is my class being tested:
@dataclass(frozen=True)
class NominationData:
title: str
url: str
is_approved: bool
articles:…

Roy Smith
- 2,039
- 3
- 20
- 27
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
Flask-Caching not connecting to redis cluster in disabled cluster mode (aws hosted)
I am using the flask-caching library to use caching in my flask app. I am following the docs here: https://flask-caching.readthedocs.io/en/latest/#redisclustercache
When trying the connection on a cluster-enabled-mode cluster locally it works,…

Lazaron Shyta
- 67
- 1
- 6
0
votes
1 answer
Delete specific route cache in Flask-Caching
I am trying to delete a flask cache on a specific route if there is an error or if a variable is empty, but i don't understand how to do it.
I have found this, but i don't think it is helpful in my case:
Delete specific cache in Flask-Cache or…

blastbeng
- 187
- 2
- 11
0
votes
0 answers
How do I cache a Flask view that returns an Image?
My function:
@app.route("/media///")
def view_media_file(collection, unique_path, filename):
document = db.find_one_or_404(collection, 'unique_path', unique_path)
hex_id = filename.rsplit(".", 1)[0]
…

scoofy
- 103
- 8
0
votes
1 answer
Slow time to first byte (TTFB) Flask with `FileSystemCache`
I'm facing slow Time to First Byte (TTFB) for my web app in Flask, after changing my linux server. The problem seams to show up only on the first time access or after cache expires (5 minutes). Sometimes TTFB reaches 16 seconds.
I confirmed the…

imbr
- 6,226
- 4
- 53
- 65
0
votes
1 answer
Error 99 while using redislite with my flask application
In my flask application I use a docker redis container (through flask caching), so I have specified the necessary parameters in the config file.
For some tests though I am using redislite and I delete the HOST and PORT from the config file. So I…

json
- 1
0
votes
1 answer
How to configure Redis_sentinel with flask app?
Currently I am using Redis for my Flask app and having the configuration as below.
redis_config =…
user17238351
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
0 answers
How to apply flask caching for a pretrained model?
I have a flask_restful api. I have divided the structure in few parts like:
app:
-api.py
-resources
--resource1.py
--resource2.py
resource1 file have structure like:
class Func(Resource):
def __init__(self):
…

fluorine
- 31
- 7
0
votes
1 answer
Flask-caching a function using blueprints
I am doing an app and I am using the Blueprints structure. My code is running okay, but I got this error while trying to implment flask-caching into one function.
The error returned is:
AttributeError: 'Blueprint' object has no attribute…

Altieres Schincariol
- 31
- 1
0
votes
0 answers
Flask FileSystem Cache for Large Datasets
I'm having a Dash Application which takes in multiple CSV files, and creates a combined Dataframe for analysis and visualization. Usually, this computation takes around 30-35 seconds for datasets of size 600-650 MB. I'm using Flask Filesystem cache…

saran sky
- 73
- 5
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