开发者

Disable cache in Pylons app under development mode

开发者 https://www.devze.com 2022-12-20 01:15 出处:网络
I\'m using @beaker_cache() decorator in my Pylons application. How can I disable the cach开发者_StackOverflow社区e under development mode?You could write your own decorator which looks at pylons.confi

I'm using @beaker_cache() decorator in my Pylons application. How can I disable the cach开发者_StackOverflow社区e under development mode?


You could write your own decorator which looks at pylons.config["debug"], and depending on that either returns function unchanged or decorated with beaker_cache. Something along these lines (completely untested!):

from pylons import config

def my_cache(*args, **kwargs):
    if config["debug"]:
        decorate = lambda f: f
    else: 
        decorate = beaker_cache(*args, **kwargs)

    return decorate
0

精彩评论

暂无评论...
验证码 换一张
取 消