[Product-Developers] plone.memoize question

Hedley Roos hedley at upfrontsystems.co.za
Thu Nov 20 09:05:56 UTC 2008


> 
> i need some help with a plone.memoize caching.
> 
> I try to cache a method on a browser view only if
> the result of the methods aktive == '1'.
> 
> This is my implementation:
> 
> def _render_details_cachekey(method, self):
>     keys = self.veryExpensiveOftenCalledMethod()
>     if keys.get('aktiv') == '1':
>         return (keys.get('user',), keys.get('aktiv'))
>     else:
>         DontCache

> 
> 
> Does this work?
> Do you see any problems with it?
> 
> Thanks for your help.
> 
> Christian
> 

I'm sure this won't work. Your expensive method is part of the 
computation of the cache key which means it will be called every single 
time rendering your caching useless.

H




More information about the Product-Developers mailing list