>     return cache.ram.storage['message'][1]
>

Where did you see that as the way to access cached values? That is not the 
proper API. Note, cache.ram.storage is not initialized until cache.ram has 
been called at least once, so unless you have a cache.ram() somewhere prior 
in the same request, cache.ram.storage will be an empty dictionary.

Instead, you should use the proper API:

    return cache.ram('message', lambda: None, None)

Using None as the third argument means the existing cached value will be 
retrieved (so the output of the lambda function is irrelevant, as it will 
never be called).
 

> def progress():
>     # when a form is submitted, change progress each second
>     if request.post_vars:
>         for i in range(5):
>             message = cache.ram('message', lambda: i, time_expire=1)
>

Note, here you want to make sure you update the cached value no matter 
what, so set time_expire to 0:

            message = cache.ram('message', lambda: i, time_expire=0)

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

Reply via email to