Hi All,
For anyone who was interested in this thread, Massimo did implement cache
decorators for use *inside modules* and this is now available in trunk. It
seemed to work OK for me and for anyone else wishing to test this, here is
the description....
Example Code for use inside your module:
from gluon.cache import lazy_lazy_cache
@lazy_lazy_cache('key', time_expire=10, cache_model='ram')
def myfunction():
import time
return time.time()
'key' is optional
time_expire defaults to 300 seconds.
cache_model defaults to 'ram'.
Note the system is the same as regular cache except that cache_model is
'ram, not cache.ram. You cannot use current.cache because cache.ram only
exists per-request.
On Monday, July 16, 2012 4:05:38 AM UTC+1, villas wrote:
>
> Ok as you asked, I raised it as issue
> 895<http://code.google.com/p/web2py/issues/detail?id=895>so you can ponder on
> it.
> As I think this might be a tricky issue, I shall pass the cache in as
> Bruno suggested and I am happy with that solution. Please mark as wontfix
> if you don't see an obvious way to implement this.
> Thanks
>
>
> On Monday, July 16, 2012 2:33:46 AM UTC+1, Massimo Di Pierro wrote:
>>
>> Not yet. Please open a ticket about this.
>>
>> On Mar 1, 2011, at 5:05 AM, Carl Roach wrote:
>>
>> thanks Massimo.
>> The ability to have cache decorators in modules would be great.
>>
>> On 1 March 2011 02:09, Massimo Di Pierro <[email protected]>wrote:
>>
>>> Jonathan and I have a plan to make this easy but it will not be in
>>> until 1.93 or 1.94.
>>>
>>> On Feb 28, 3:12 pm, pbreit <[email protected]> wrote:
>>> > Yeah, I'm having a hard time figuring out when and how to put stuff in
>>> > modules. And what the implications are of putting functions in /models.
>>>
>>
>>
>>
--