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
This commit is contained in:
parent
26aa91568b
commit
cdb9bc94d0
2 changed files with 6 additions and 3 deletions
|
@ -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
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -63,7 +63,7 @@ class CacheItem(object):
|
||||||
self.value = INVALID
|
self.value = INVALID
|
||||||
|
|
||||||
|
|
||||||
def cache(getIdentifier, lifetime=3600):
|
def internalCache(getIdentifier, lifetime=3600):
|
||||||
def _cache(fct):
|
def _cache(fct):
|
||||||
def __cache(*args, **kw):
|
def __cache(*args, **kw):
|
||||||
id = getIdentifier(*args, **kw)
|
id = getIdentifier(*args, **kw)
|
||||||
|
@ -76,6 +76,8 @@ def cache(getIdentifier, lifetime=3600):
|
||||||
return __cache
|
return __cache
|
||||||
return _cache
|
return _cache
|
||||||
|
|
||||||
|
cache = internalCache
|
||||||
|
|
||||||
|
|
||||||
# memcached implementation
|
# memcached implementation
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ Data Caching
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
>>> from cybertools.util.cache import cache
|
>>> from cybertools.util import cache
|
||||||
|
>>> cache = cache.internalCache
|
||||||
|
|
||||||
>>> @cache(lambda *args: 'calc')
|
>>> @cache(lambda *args: 'calc')
|
||||||
... def calculate():
|
... def calculate():
|
||||||
|
|
Loading…
Add table
Reference in a new issue