this is the correct behavior in a multi-process/multi-thread environment 
because cache.ram is not shared across them.
use either memcache or redis to have a global cache

Paolo

On Wednesday, May 20, 2015 at 1:46:48 PM UTC+2, Lisandro wrote:
>
> Are there any special consideration about @cache.action in production with 
> nginx + uwsgi? I'm having problems using it, so I made a simple test to 
> show you.
>
> In the default welcome application, in default.py controller:
>
> @cache.action(time_expire=30, cache_model=cache.ram, session=False, vars=
> False, public=True)
> def test():
>     return request.now.strftime('%H:%M:%S')
>
> Now, the first time you hit the /test url, you will see the current time. 
> But if you inmediately hit the url again, you will see the time shown in 
> the first hit. This time will be shown for 30 seconds, that is, the result 
> of the function is cached for 30 seconds.
>
> This works ok with web2py's embedded server. 
> However, when I move it to nginx + uwsgi, @cache.action behaves strangely:
> 1) When I first hit the url, I see the current time.
> 2) Three seconds after, I hit the url again, and I don't see cached time, 
> instead, I see again the current time.
> 3) Three or four seconds after, I hit the url again, and I see the first 
> cached time.
> 4) I keep hitting the url, and it keeps returning previously cached 
> values, randomly. But something is shure: it never returns a value for 30 
> seconds, the code is executed at least every 4 o 5 seconds. So in a period 
> of 30 seconds, no matter how many times I hit the url, the returned values 
> will always differ 4 o 5 seconds between them.
>
> Am I missing something? Is it necesarry to configure some nginx's stuff? I 
> don't think it would be necessary. 
>

-- 
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