-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Description
The function _memoize_version which is used within the @cache.memoize() decorator can generate keys that are invalid for memcached.
I am using pylibmc==1.5.0 and Flask-Cache==0.13.1
I instantiate the pylibmc client with the behavior of verify_keys.
cache = Cache(app, config={
'CACHE_TYPE': 'memcached',
# The reason we pass in a client directly is because the keys that flask-cache uses somehow break
# in Python 3. I don't know why, but I managed to trace the code far enough to know that if we were
# to send a client directly in then the Werkzeug cache backend would use it directly. This, as far
# as I know is the only way to get Pylibmc options into the client init.
'CACHE_MEMCACHED_SERVERS': pylibmc.Client(['127.0.0.1:11211'], behaviors={'verify_keys': True}),
})The reason I do this is because when I switched to Python 3 the cache keys were breaking and verify keys seemed to fix it. As I look back on it now, maybe instead of fixing it it simply caused the errors to be hidden.
I see two potential issues:
- You do not look at the response from the set command to see if the set was successful, thus hiding potential issues when setting a key does not succeed.
- Some functions use raw un-hashed keys which are incompatible with some cache backends.
Switching my client from pylibmc to python-memcached it properly throws an exception for bad key errors coming from _memoize_version.
Metadata
Metadata
Assignees
Labels
No labels