I'm sure technically there's some double laziness going on, but from an API 
standpoint, maybe it would be sufficient to just include one "lazy" in the 
name. :-)  Another option might be current_cache.

Anthony

On Wednesday, July 25, 2012 5:25:36 PM UTC-4, Massimo Di Pierro wrote:
>
> Because while the cache decorator wraps the function once. The 
> lazy_lazy_cache wraps cache once, therefore the function twice. This is 
> because cache requires current.request but this is only available when the 
> function is called, not when the module is first imported and the cache 
> decorator executed. I am not attached to the name anyway, we can change it.
>
> On Wednesday, 25 July 2012 09:44:20 UTC-5, Anthony wrote:
>>
>> Why is it called lazy_lazy_cache, as opposed to just lazy_cache?
>>
>> On Wednesday, July 25, 2012 10:36:50 AM UTC-4, villas wrote:
>>>
>>> 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 
>>>>> <massimo.dipie...@gmail.com>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 <pbreitenb...@gmail.com> 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.
>>>>>>
>>>>>
>>>>>
>>>>>

-- 



Reply via email to