Skip to content

Instantly share code, notes, and snippets.

@thejefflarson
Created April 27, 2009 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejefflarson/102775 to your computer and use it in GitHub Desktop.
Save thejefflarson/102775 to your computer and use it in GitHub Desktop.
""" 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