Alex Rivera | Logout

How do I use beaker caching in Pyramid?

Asked 2011-02-19T10:03:09.967
9

I have the following in my ini file:

cache.regions = default_term, second, short_term, long_term
cache.type = memory
cache.second.expire = 1
cache.short_term.expire = 60
cache.default_term.expire = 300
cache.long_term.expire = 3600

And this in my __init__.py:

from pyramid_beaker import set_cache_regions_from_settings
set_cache_regions_from_settings(settings)

However, I'm not sure how to perform the actual caching in my views/handlers. Is there a decorator available? I figured there would be something in the response API but only cache_control is available - which instructs the user to cache the data. Not cache it server-side.

Any ideas?

Edit
Report

1 Answer

1

Same problem here, you can perform caching using default parameters with

from beaker.cache import CacheManager

and then decorators like

@cache.cache('get_my_profile', expire=60)

lik in http://beaker.groovie.org/caching.html, but I can't find the solution how to make it work with pyramid .ini configuration.

answered 2011-02-20T01:51:02.750

Your Answer