Skip to content

Memcache key length > 250 #31

@max-barry

Description

@max-barry

Liking this module and Prismic in general.

I noticed that package uses the fetch url as the cache key. If you're search query was long, or you use an ACCESS_TOKEN (the ones Prismic generate are long) in your call, then that URL is going to be really long and the key will be over 250 characters.

That will throw a hard exception in most Python memcache packages.

I'm using pylibmc but the Memcache client doesn't matter. The 250 character limit on cache keys is fundamental to Memcache.

Example of a key that threw an exception for me:

https://<MY_6_CHARACTER_DOMAIN>.prismic.io/api/v1/documents/search?access_token=<MY_ACCESS_TOKEN>&q=%5B%5B%3Ad+%3D+at%28my.content_post.uid%2C+%22my-test-slug%22%29%5D%5D&ref=Wa_fDS0AAI1WhU1d&page=1&pageSize=1

Proposed solutions
Potentially don't use the hostname in the key? It's still risky that with an access token and complicated query it nudges over 250 characters.

Hash the query dictionary in some way that it creates a much shorter string than the URL.

Interim solution
I'm making my Master API public and not using the access token, which is easily the longest thing in the URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions