cache.with_prefix(cache.ram,'prefix'), thanks Bruno

This commit is contained in:
mdipierro
2012-09-14 16:08:25 -05:00
parent 5f503d0427
commit 00bfde9ce9
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.0.9 (2012-09-14 15:51:53) stable
Version 2.0.9 (2012-09-14 16:08:21) stable
+11
View File
@@ -479,6 +479,17 @@ class Cache(object):
return CacheAction(func,key,time_expire,self,cache_model)
return tmp
@staticmethod
def with_prefix(cache_model, prefix):
"""
allow replacing cache.ram with cache.with_prefix(cache.ram,'prefix')
it will add prefix to all the cache keys used.
"""
return lambda key, f, time_expire=DEFAULT_TIME_EXPIRE, prefix=prefix:\
cache_model(prefix + key, f, time_expire)
def lazy_cache(key=None,time_expire=None,cache_model='ram'):
"""
can be used to cache any function including in modules,