From 4031b49d77e4c5f779e743d3dd450db127fc7dea Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 14 Sep 2012 16:08:25 -0500 Subject: [PATCH] cache.with_prefix(cache.ram,'prefix'), thanks Bruno --- VERSION | 2 +- gluon/cache.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 18537964..a4c6bea4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.9 (2012-09-14 15:51:53) stable +Version 2.0.9 (2012-09-14 16:08:21) stable diff --git a/gluon/cache.py b/gluon/cache.py index 23626f40..8d9c1c63 100644 --- a/gluon/cache.py +++ b/gluon/cache.py @@ -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,