summaryrefslogtreecommitdiff
path: root/django/core/cache/backends/filebased.py
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2007-10-26 20:47:20 +0000
committerJustin Bronn <jbronn@gmail.com>2007-10-26 20:47:20 +0000
commit4ffbddf92d89c3b31cef90043721184a501cd454 (patch)
treedb8131d40b0a5437270a6b1e8d579113ab3508e8 /django/core/cache/backends/filebased.py
parentf66ee9d0065838a0f6c9c76203a775a78446cdf7 (diff)
gis: Merged revisions 6525-6613 via svnmerge from [repos:django/trunk trunk].
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6615 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/cache/backends/filebased.py')
-rw-r--r--django/core/cache/backends/filebased.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/django/core/cache/backends/filebased.py b/django/core/cache/backends/filebased.py
index d5415c8ace..690193ac81 100644
--- a/django/core/cache/backends/filebased.py
+++ b/django/core/cache/backends/filebased.py
@@ -17,6 +17,26 @@ class CacheClass(SimpleCacheClass):
del self._cache
del self._expire_info
+ def add(self, key, value, timeout=None):
+ fname = self._key_to_file(key)
+ if timeout is None:
+ timeout = self.default_timeout
+ try:
+ filelist = os.listdir(self._dir)
+ except (IOError, OSError):
+ self._createdir()
+ filelist = []
+ if len(filelist) > self._max_entries:
+ self._cull(filelist)
+ if os.path.basename(fname) not in filelist:
+ try:
+ f = open(fname, 'wb')
+ now = time.time()
+ pickle.dump(now + timeout, f, 2)
+ pickle.dump(value, f, 2)
+ except (IOError, OSError):
+ pass
+
def get(self, key, default=None):
fname = self._key_to_file(key)
try: