Need to invalidate a cache created by beaker_cache
decorator for a specific controller action:
from pylons.decorators.cache import beaker_cache
class SampleController(BaseController):
@beaker_cache()
def home(self):
c.data = expensive_call()
return render('/home.myt')
def __clear_home_cache(self):
pass
Can I use region_invalidate()
inside __clear_home_cache function?
One way to find out how to invalidate stuff cached by
beaker_cache
decorator is to look at how it works and what it does. It is defined inpylons.decorators.cache
module, here's the corresponding source file on GitHub.Basically you're looking for the logic that chooses namespace and cache key for a given controller action. This is done by create_cache_key() function in that file. And, incidentally, that function has a helpful comment: