Created
April 27, 2009 22:14
-
-
Save thejefflarson/102775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Idea taken from here: http://github.com/ericflo/django-tokyo-sessions/tree/master | |
Basically this is a thin wrapper around django's cache fremwork to allow for persistent | |
keys with no expiration values. | |
I'm using it to store unique values that get updated infrequently, ie via cron, and which | |
don't need to expire, just be updatable. | |
Requires TT_PERSISTENT_STORE to be set in settings.py using the memcached format. | |
""" | |
import pytyrant | |
from django.core.exceptions import ImproperlyConfigured | |
from django.conf import settings | |
from django.core.cache import get_cache | |
TT_PERSISTENT_STORE = getattr(settings, 'TT_PERSISTENT_STORE', None) | |
if TT_PERSISTENT_STORE is None: | |
raise ImproperlyConfigured(u'To use the persistent store you need to set TT_PERSISTENT_STORE in your settings.py file') | |
tyrant_store = get_cache(TT_PERSISTENT_STORE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment