Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memcache key length > 250 #31

Open
max-barry opened this issue Sep 6, 2017 · 1 comment
Open

Memcache key length > 250 #31

max-barry opened this issue Sep 6, 2017 · 1 comment

Comments

@max-barry
Copy link

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.

@srenault
Copy link
Contributor

srenault commented Sep 8, 2017

Thanks for your report.
We're going to work on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants