-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
bugSomething isn't workingSomething isn't workingcaching decoratorthings to do with cache on arguments, etcthings to do with cache on arguments, etcdocumentationregion
Description
Problem
Hi I think dogpile.cache is really awesome, however I've been encountering an issue using the memcached backend:
It looks like dogpile.cache uses __repr__ or __str__ of the parameters to the cached function for the default key. When caching a sequence, this means that the key can be very large. memcached however has a fixed key limit of 250. The solution to the error is nonobvious (implementing one's own key_mangler)
Here is the error in question
ValueError: key length 63566 too long, max is 250
> /home/user/envs/mypackage/lib/python3.7/site-packages/dogpile/cache/region.py(1360)get_or_create_for_user_func()
In the interest of usability, I would recommend adding default key_mangler, for all or certain backends. Or at least, there should be caveats section in the documentation.
Workaround Solution
Since someone else will likely encounter this, I will post my solution using the xxhash library:
from xxhash import xxh64_hexdigest
region = make_region(key_mangler=xxh64_hexdigest)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcaching decoratorthings to do with cache on arguments, etcthings to do with cache on arguments, etcdocumentationregion