beaker configuration

26 views
Skip to first unread message

Jason

unread,
Nov 14, 2011, 2:49:19 PM11/14/11
to pylons-...@googlegroups.com
Whenever  I call a method decorated with cache_region it is still executing the method every time it is called (as I see with a print statement while in development).

I have my beaker config in the 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

Which get configured as regions in main():

pyramid_beaker.set_cache_regions_from_settings(settings)

In the handler (I'm using pyramid_handlers) I have imported "from beaker.cache import cache_region" and then used the decorator as:

@cache_region('default_term', 'contacts')
def _get_contacts(self, userid):
    print 'retrieving contacts'
    # get contacts from another server
    return contacts

This is being called from a view-callable.

Is there something simple I am overlooking, this is all the setup that I have seen required in the pyramid_beaker and beaker documentation.


Thanks,
Jason

Michael Merickel

unread,
Nov 14, 2011, 4:18:14 PM11/14/11
to pylons-...@googlegroups.com
This is probably because the arguments to the method change every time the method is called. i.e. "self" is a different instance of your class every time.

Jason

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/wbJZX5hgbFQJ.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.



--

Michael

Jason

unread,
Nov 14, 2011, 4:21:37 PM11/14/11
to pylons-...@googlegroups.com
You're absolutely right. Caching instance methods with the cache_region decorator is only supported in Beaker 1.6 and higher. I'm using 1.5.4 (thanks for debug toolbar letting me easily see the versions).

-- Jason

Michael Merickel

unread,
Nov 14, 2011, 4:25:17 PM11/14/11
to pylons-...@googlegroups.com
Don't upgrade to 1.6 quite yet. pyramid_beaker doesn't support it until its next release which I hope will be very soon.

On Mon, Nov 14, 2011 at 3:21 PM, Jason <ja...@deadtreepages.com> wrote:
You're absolutely right. Caching instance methods with the cache_region decorator is only supported in Beaker 1.6 and higher. I'm using 1.5.4 (thanks for debug toolbar letting me easily see the versions).

-- Jason

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/3uaZLUSqQYoJ.

To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.



--

Michael

Mattias

unread,
Nov 19, 2011, 6:45:14 AM11/19/11
to pylons-discuss
Is this still the case? Right now the requirements for pyramid_beaker
is "beaker" so easy_install pulls in the latest beaker which is
"Beaker 1.6.1"

Mattias

unread,
Nov 19, 2011, 6:54:24 AM11/19/11
to pylons-discuss
I reverted to beaker 1.5.4 for now by using

easy_install -mxN beaker
easy_install beaker==1.5.4

and then removed the Beaker-1.6.1-py2.7.egg folder from the site-lib.

Michael Merickel

unread,
Nov 19, 2011, 1:40:40 PM11/19/11
to pylons-...@googlegroups.com
I just pushed out 0.6.1, please let me know if that solves your 1.6 issues.

--

Michael

Jason

unread,
Nov 21, 2011, 10:35:09 AM11/21/11
to pylons-...@googlegroups.com
I had already started using beaker 1.6 and it seem to work fine as long as I included a key_length key for each region definition:

cache.short_term.expire = 60
cache.short_term.key_length = 256
Reply all
Reply to author
Forward
0 new messages