Skip to content

Instantly share code, notes, and snippets.

View matclayton's full-sized avatar
🚀
Focusing

Mat Clayton matclayton

🚀
Focusing
View GitHub Profile
from datetime import datetime, timedelta
from dateutil.parser import parse as iso8601
from celery.task.base import Task
from celery.utils import timedelta_seconds
class ExpireTask(Task):
"""Task with an expiration time.
"""
Thread-safe Django cache backend for pylibmc.
Tested on Python 2.6, should work on 2.5 as well.
Use it by setting CACHE_BACKEND in settings.py, e.g.:
CACHE_BACKEND = 'projdir.utils.pylibmcd://127.0.0.1:11211/'
"""
from __future__ import with_statement
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
"libMemcached cache backend"
from django.core.cache.backends.base import (BaseCache,
InvalidCacheBackendError)
from django.utils.encoding import smart_unicode, smart_str
try:
import pylibmc as memcache
is_pylibmc = True
except ImportError: