hello. I understand that i can cache the values. But my question is where
do i put that cache.ram statement. Do I put it in a model? but then that
cache statement is executed every request.
What i would like to cache is group ids for the memberships. I would like
to lookup a role out of the auth_group table and store the id.
On Thursday, April 5, 2012 at 8:14:57 AM UTC-7, Anthony wrote:
>
> Here how I do caching :
>>
>> dblabels_en=dict([(r.table_name+r.column_name,r.column_name_en_ui)\
>> for r in db().select(db.dict_database.ALL,cache=(cache.ram,3600))])
>>
>> The problem, is that I think the for and dict creation are re-executed
>> each request.
>>
>
> Why don't you just store the final dict in the cache instead of caching
> the select:
>
> dblabels_en = cache.ram('dblabels_en',
> lambda: dict([(r.table_name + r.column_name, r.column_name_en_ui)
> for r in db().select(db.dict_database.ALL)]),
> time_expire=3600)
>
> Anthony
>
--
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.