コード例 #1
0
 def wrapped_f(cls, *args, **kwargs):
     cache_key = key(*args, **kwargs)
     o = tables_cache.get(cache_key)
     if not kwargs['force'] and o is not None:
         return o
     o = f(cls, *args, **kwargs)
     tables_cache.set(cache_key, o, timeout=timeout)
     return o
コード例 #2
0
 def wrapped_f(cls, *args, **kwargs):
     cache_key = key(*args, **kwargs)
     o = tables_cache.get(cache_key)
     if not kwargs['force'] and o is not None:
         return o
     o = f(cls, *args, **kwargs)
     tables_cache.set(cache_key, o, timeout=timeout)
     return o
コード例 #3
0
ファイル: cache.py プロジェクト: bkyryliuk/caravel
            def wrapped_f(self, *args, **kwargs):
                if not kwargs.get('cache', True):
                    return f(self, *args, **kwargs)

                if attribute_in_key:
                    cache_key = key(*args, **kwargs).format(
                        getattr(self, attribute_in_key))
                else:
                    cache_key = key(*args, **kwargs)
                o = tables_cache.get(cache_key)
                if not kwargs.get('force') and o is not None:
                    return o
                o = f(self, *args, **kwargs)
                tables_cache.set(cache_key, o,
                                 timeout=kwargs.get('cache_timeout'))
                return o
コード例 #4
0
            def wrapped_f(self, *args, **kwargs):
                if not kwargs.get('cache', True):
                    return f(self, *args, **kwargs)

                if attribute_in_key:
                    cache_key = key(*args, **kwargs).format(
                        getattr(self, attribute_in_key))
                else:
                    cache_key = key(*args, **kwargs)
                o = tables_cache.get(cache_key)
                if not kwargs.get('force') and o is not None:
                    return o
                o = f(self, *args, **kwargs)
                tables_cache.set(cache_key,
                                 o,
                                 timeout=kwargs.get('cache_timeout'))
                return o