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

cache key can be invalid #1

Open
carljm opened this issue Feb 3, 2010 · 1 comment
Open

cache key can be invalid #1

carljm opened this issue Feb 3, 2010 · 1 comment

Comments

@carljm
Copy link

carljm commented Feb 3, 2010

The Chunk key field is a CharField, which can take almost any kind of character data, including Unicode, spaces, whatever.

In the templatetag, the chunk key is used as part of the cache key. If using memcached with python-memcached, even spaces are illegal in a cache key. This causes 500 errors.

My first solution was to slugify the chunk key before using it as cache key. This works, but raises the possibility of two overly-similar (but still unique) chunk keys slugifying to the same cache key and stomping over each other's cache. The only way this would really work is if chunks gained an actual SlugField with uniqueness enforced.

So my second solution (found in my fork) was to rip out the direct caching support entirely. IMO there's no reason for django-chunks to have its own (buggy) cache support, when its just as easy (and more flexible) to wrap calls to the chunk tag with Django's built-in template fragment caching tags.

@igorsobreira
Copy link
Contributor

+1 to remove the cache support. Just use the template fragment caching.

Also, today it caches the Chunk object, not just the content string. This just makes the cache bigger than necessary.

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