Do you mean that it should work adding only that lines in models/0_memcache.py? I've tried that but the results are still the same :/
I was asking about the nginx/uwsgi part because I thought some configuration was required. In case it doesn't require any additional configuration to nginx/uwsgi, then I don't understand why cache isn't working yet. I'm using web2py 2.10.4 with nginx + uwsgi. Also, I don't have any additional local stuff, it's just the welcome app with that simple test function in default controller, and those lines in models/0_memcache.py. All that, running with nginx and uwsgi. El miércoles, 20 de mayo de 2015, 10:35:35 (UTC-3), Paolo Valleri escribió: > > The web2py part you have posted is more than enough. Did you try it? > memcache with nginx is an other thing > > > Paolo > > 2015-05-20 15:03 GMT+02:00 Lisandro <[email protected] <javascript:>>: > >> Thank you very much for the clarification. >> >> Do you know about some example of nginx+uwsgi configuration with >> memcache? I've already read this documentation: >> http://web2py.com/books/default/chapter/29/13/deployment-recipes#Memcache >> http://nginx.org/en/docs/http/ngx_http_memcached_module.html >> >> I've already created the model file models/0_memcache.py with this code: >> >> from gluon.contrib.memcache import MemcacheClient >> memcache_servers = ['127.0.0.1:11211'] >> cache.memcache = MemcacheClient(request, memcache_servers) >> cache.ram = cache.disk = cache.memcache >> >> But I'm not shure about my nginx virtual host configuration. I'm >> concerned about which should be the proper way of combining "all the stuff" >> in the nginx's virtual server configuration (by "all the stuff" I mean, >> gzip, location rules for static content, uwsgi pass, etc). >> >> This is the actual nginx's virtual server configuration that I've tried, >> but it doesn't work (the website works ok, but still no caching). >> >> server { >> listen 80; >> server_name dev.demo; >> root /home/gonguinguen/medios; >> >> location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { >> alias /home/gonguinguen/medios/applications/$1/static/$2; >> expires max; >> } >> >> location ~* ^/(\w+)/static/ { >> root /home/gonguinguen/medios/applications; >> expires max; >> } >> >> location / { >> set $memcached_key "$uri?$args"; >> memcached_pass 127.0.0.1:11211; >> error_page 404 502 504 = @fallback; >> >> uwsgi_pass unix:///tmp/medios.socket; >> include uwsgi_params; >> uwsgi_param UWSGI_SCHEME $scheme; >> uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; >> } >> >> location @fallback { >> uwsgi_pass unix:///tmp/medios.socket; >> } >> } >> >> >> >> >> I don't know where to or how to check if memcache is caching. >> >> Thanks in advance! >> >> >> >> El miércoles, 20 de mayo de 2015, 9:11:58 (UTC-3), Paolo Valleri escribió: >>> >>> 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 a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/P_ezuB93DAY/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected] <javascript:>. >> 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

