From aaedb68331adffafeb2a93e0b65b1d68a7764e64 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 22 Apr 2011 12:07:20 +0200 Subject: [PATCH] [ADD]: dummy cache class replacement. bzr revid: vmt@openerp.com-20110422100720-5ffk1tp944b53c7a --- openerp/tools/misc.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/openerp/tools/misc.py b/openerp/tools/misc.py index 276274563be..723a3a5f2ea 100644 --- a/openerp/tools/misc.py +++ b/openerp/tools/misc.py @@ -717,7 +717,28 @@ def is_hashable(h): except TypeError: return False -class cache(object): +class dummy_cache(object): + """ Cache decorator replacement to actually do no caching. + + This can be useful to benchmark and/or track memory leak. + + """ + + def __init__(self, timeout=None, skiparg=2, multi=None, size=8192): + pass + + def clear(self, dbname, *args, **kwargs): + pass + + @classmethod + def clean_caches_for_db(cls, dbname): + pass + + def __call__(self, fn): + fn.clear_cache = self.clear + return fn + +class real_cache(object): """ Use it as a decorator of the function you plan to cache Timeout: 0 = no timeout, otherwise in seconds @@ -842,6 +863,9 @@ class cache(object): cached_result.clear_cache = self.clear return cached_result +# TODO make it an option +cache = real_cache + def to_xml(s): return s.replace('&','&').replace('<','<').replace('>','>')