Hello,

Still struggle with this. I don't understand why cache dict is not updated
in real time...

It get updated but there is a strange delay.

Thanks

Richard

On Mon, Jan 4, 2016 at 4:18 PM, Richard Vézina <ml.richard.vez...@gmail.com>
wrote:

> UP here!
>
> Any help would be appreciate...
>
> Richard
>
> On Mon, Dec 21, 2015 at 10:22 PM, Richard <ml.richard.vez...@gmail.com>
> wrote:
>
>> Hello,
>>
>> I am still under 2.9.5, I have a simple dict cached in ram which never
>> expire that I update when new key value are added to the system... Mainly
>> the dict contain id and their representation...
>>
>> It works flawlessly in dev, but once I pushed in prod, it seems that the
>> cached dict takes time to really update... Here how I manage the creation
>> an update of this dict :
>>
>> def set_id_represent(update_id_represent_if_elapsed_time=None, id=None):
>>     """
>>     Calling this function will create in globals the "id_represent"
>> variable if the call is made without
>>     id. If id is passed, it will update the id_represent dictionary with
>> new
>>     id and it representation.
>>     :param id:
>>     :param update_id_represent_if_elapsed_time:
>>     """
>>     if 'id_represent' not in globals():
>>         global id_represent
>>         id_represent = \
>>             cache.ram('id_represent',
>>                       lambda: {r.id: r.represent_field
>>                                for r in db().select(db.table_name.id,
>>                                                     db.table_name.
>> represent_field,
>>                                                     orderby=db.table_name
>> .represent_field)
>>                                },
>>                       time_expire=update_id_represent_if_elapsed_time)
>>     elif isinstance(id, int) or isinstance(id, long):
>>         id_represent_query = \
>>             db(db.table_name.id == id
>>                ).select(db.table_name.id,
>>                         db.table_name.represent_field,
>>                         orderby=db.table_name.represent_field)
>>         id_represent.update({r.id: r.represent_field for r in
>> id_represent_query})
>>     if id:
>>         return id_represent[id]
>>
>> set_id_represent(update_id_represent_if_elapsed_time=None)
>>
>> Then when I want to update the cached dict with new k, v :
>>
>> set_id_represent(id=my_id)
>>
>> I have made some test and print after the id_represent.update(...) above
>> from the function call and the dict seems to be updated... The function
>> that call set_in_represent(id=id) doesn't failed, but when we want to
>> access page which user id_represent[some_id], they all failed for a couples
>> of minutes... Like if the cached dict not get update immediately...
>>
>> Thanks for any pointer...
>>
>> Richard
>>
>>
>>
>>
>>
>> --
>> 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 web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to