Ejemplo n.º 1
0
 def decorate(func):
     namespace = util.func_namespace(func)
     def cached(*args):
         if not cache[0]:
             cache[0] = self.get_cache(namespace, **kwargs)
         cache_key = key + " " + " ".join(str(x) for x in args)
         def go():
             return func(*args)
         return cache[0].get_value(cache_key, createfunc=go)
     cached._arg_namespace = namespace
     return cached
Ejemplo n.º 2
0
        def decorate(func):
            namespace = util.func_namespace(func)

            def cached(*args):
                if not cache[0]:
                    cache[0] = self.get_cache(namespace, **kwargs)
                cache_key = key + " " + " ".join(str(x) for x in args)

                def go():
                    return func(*args)

                return cache[0].get_value(cache_key, createfunc=go)

            cached._arg_namespace = namespace
            return cached
Ejemplo n.º 3
0
    def decorate(func):
        namespace = util.func_namespace(func)
        def cached(*args):
            reg = cache_regions[region]
            if not reg.get('enabled', True):
                return func(*args)

            if not cache[0]:
                if region not in cache_regions:
                    raise BeakerException('Cache region not configured: %s' % region)
                cache[0] = Cache._get_cache(namespace, reg)

            cache_key = " ".join(map(str, deco_args + args))
            def go():
                return func(*args)

            return cache[0].get_value(cache_key, createfunc=go)
        cached._arg_namespace = namespace
        cached._arg_region = region
        return cached
Ejemplo n.º 4
0
    def decorate(func):
        namespace = util.func_namespace(func)

        def cached(*args):
            reg = cache_regions[region]
            if not reg.get('enabled', True):
                return func(*args)

            if not cache[0]:
                if region not in cache_regions:
                    raise BeakerException('Cache region not configured: %s' %
                                          region)
                cache[0] = Cache._get_cache(namespace, reg)

            cache_key = " ".join(map(str, deco_args + args))

            def go():
                return func(*args)

            return cache[0].get_value(cache_key, createfunc=go)

        cached._arg_namespace = namespace
        cached._arg_region = region
        return cached