flask-caching
flask-caching copied to clipboard
ERR _pickle.UnpicklingError: invalid load key, '\x7f'.
Get this a lot, makes caching entirely unusable
Please provide some details, like a backtrace; a minimum working example would help a lot too. Without these, we’re in the dark.
I have same problem with this with:
- python 3.8
- flask-caching 1.10.1
- Ubuntu 16.04 on PythonAnywhere server
- cache = Cache(config={'CACHE_TYPE': 'FileSystemCache', 'CACHE_DEFAULT_TIMEOUT': 86400*2, 'CACHE_THRESHOLD': 1000, 'CACHE_DIR': FULL_STATIC_YT_DIR})
- Are there any restrict in key & value in set&get function?
- Here is log
cache.set(name, r.content) # insert content to cache File "/home/ccpython1/.virtualenvs/web101/lib/python3.8/site-packages/flask_caching/__init__.py", line 267, in set return self.cache.set(*args, **kwargs) File "/home/ccpython1/.virtualenvs/web101/lib/python3.8/site-packages/flask_caching/backends/filesystemcache.py", line 209, in set self._prune() File "/home/ccpython1/.virtualenvs/web101/lib/python3.8/site-packages/flask_caching/backends/filesystemcache.py", line 142, in _prune expires = pickle.load(f) _pickle.UnpicklingError: invalid load key, 'v'.
But i test on my Mac 11.4, with same config, it work OK! :(
It maybe some files already have in CACHE_DIR folder not generate by Flask-Caching have cause it fail. I remove all this files & it work OK! Maybe we need warning & document on this problem?
@cuongtv51 Same issue here. Everything worked fine before. Just made a new installation and then... this is starting to show up. Even deleting the caching folder is not solving.
Its probably related to https://github.com/pallets-eco/flask-caching/issues/93.
When running
cache.set('points_verd', points_verd)
cache.set('points', points)
I get errors like:
get key '__wz_cache_count' -> invalid load key, '\x00'.
get key '__wz_cache_count' -> invalid load key, '\x00'.
And when running
x = cache.get('points')
y = cache.get('points_verd')
get key 'points' -> invalid load key, '&'.
get key 'points_verd' -> invalid load key, '&'.
My code was running fine two weeks ago. I just had to format my server due disk corruption and after re-installing that's happening. I almost sure it's coming from here.
My app is very small and its flask-cacching config is as follow in a Python3.8 on a orangepi zero 2. Ubuntu Focal Server.
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 8*60*60 # 8 hours in seconds
app.config['Debug'] = False
app.config['SECRET_KEY'] = secrets.token_hex(16)
# Flask-Cache package
app.config['CACHE_THRESHOLD'] = 10000
app.config['CACHE_DIR'] = os.path.join(tempfile.gettempdir(), "careas_apps") # temporary directory
app.config['CACHE_TYPE'] = 'FileSystemCache'
cache = Cache(app)
Just confirmed reverting back to previous release solved the problem. So for future folks:
pip install Flask-Caching==1.10.1
Latest release 1.11.1 is breaking everything. I can see they refactored everything almost on 'FileSystemCache' and they broke it.
Unfortunately I don't have time to create a minimal reproducible code right now.
Still getting these errors with 1.10.1
ERROR:flask_caching.backends.filesystemcache:get key 'progress' -> invalid load key, '\x04'.
Just confirmed reverting back to previous release solved the problem. So for future folks:
pip install Flask-Caching==1.10.1
Latest release 1.11.1 is breaking everything. I can see they refactored everything almost on 'FileSystemCache' and they broke it. Unfortunately I don't have time to create a minimal reproducible code right now.
Saved my evening! Thank you.
Just confirmed reverting back to previous release solved the problem. So for future folks:
pip install Flask-Caching==1.10.1
Latest release 1.11.1 is breaking everything. I can see they refactored everything almost on 'FileSystemCache' and they broke it. Unfortunately I don't have time to create a minimal reproducible code right now.
This, If I would've found this 3 [h] before haha, thank you
Same issue here. Pinning to 1.10.1 solves this.
Found this solution after 2 days of failing to have dash_extensions.enrich ServersideOutput working. Reverting to flask-caching==1.10.1 form 1.11.1 fixed the "key '__wz_cache_count' -> invalid load key, '\x00'." error.