Likewise, I too am confused by Massimo's suggestion of using:

if cache.ram('init',lambda:db(db.auth_user).isempty(),None):
   arbitrary_function()


The True value indicating auth_user is empty is stored in the cache.ram 
'init' value, then never updated.   In my test code, 'arbitary_function' 
gets executed every time a page is loaded (since True for .isempty() is 
cached), even after records are added to auth_user....

It's only after I stop web2py, restart (and the new value is stored in 
cache.ram 'init' does the function stop being executed.

How can setting a cache.ram value then setting the expiration of the value 
to None / never expire every work?





On Monday, March 31, 2014 at 2:57:00 PM UTC-5, Jay Martin wrote:
>
> I'm confused as to why this scenario needs caching.
>
> Isn't it true that for an empty user table:
>
> if cache.ram('init',lambda:db(db.auth_user).isempty(),None):
>    arbitrary_function()
>
> will only cache the boolean value True and keep that value (True) in cache 
> forever (until the app is restarted), associated with the given key 'init'?
>
> Therefore, only this initial state is remembered. All future executions of 
> this code will only ever return this initial value (True), therefore the 
> subsequent arbitrary function will continue to be executed every cycle of 
> execution.
>
> Am I missing something? Many thanks!
>
>
>
> On Friday, August 10, 2012 11:23:56 PM UTC-4, Massimo Di Pierro wrote:
>>
>> you stil want to cache that
>>
>> if cache.ram('init',lambda:db(db.mytable).isempty(),None):
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to