Skip to content

warn / document that keymangler is generally needed w/ the function decorators #182

Open
@brycepg

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions