From cdb9bc94d0fd447ec477aaca39df71bedd7ef82b Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 26 Mar 2010 11:18:13 +0000 Subject: [PATCH] make internal cache implementation available for testing even when lovely.memcached is present git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3784 fd906abe-77d9-0310-91a1-e0d9ade77398 --- util/cache.py | 6 ++++-- util/cache.txt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/util/cache.py b/util/cache.py index a606e7e..14268a3 100644 --- a/util/cache.py +++ b/util/cache.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2009 Helmut Merz helmutm@cy55.de +# Copyright (c) 2010 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ class CacheItem(object): self.value = INVALID -def cache(getIdentifier, lifetime=3600): +def internalCache(getIdentifier, lifetime=3600): def _cache(fct): def __cache(*args, **kw): id = getIdentifier(*args, **kw) @@ -76,6 +76,8 @@ def cache(getIdentifier, lifetime=3600): return __cache return _cache +cache = internalCache + # memcached implementation diff --git a/util/cache.txt b/util/cache.txt index e6ed568..4982842 100644 --- a/util/cache.txt +++ b/util/cache.txt @@ -4,7 +4,8 @@ Data Caching $Id$ - >>> from cybertools.util.cache import cache + >>> from cybertools.util import cache + >>> cache = cache.internalCache >>> @cache(lambda *args: 'calc') ... def calculate():