Let me post a more detailed example. This is a test with three applications.
Two of them ("demo" and "fundapres") use redis to cache the html for default/index, with this decorator (notice empty prefix): @cache.action(time_expire=30, cache_model=cache.redis, session=False, vars= False, public=True, prefix='') The third doesn't directly use redis to cache, but instantiates it to show cache.redis.stats(). Acordingly to documentation, the stats() method "returns a dictionary with statistics of Redis server with one additional key ('w2p_keys') showing all keys currently set from web2py with their TTL" If I don't misunderstand that, w2p_keys shows all keys currently set from web2py for all the installed apps that are using redis. The first test. Hitting these two urls: /demo/default/index /fundapres/default/index Everything works ok. When I check cache.redis.stats (from the third application) I see this w2p_keys:w2p:webmedios:075da5fa9bae34693cee9778e8b893c2_expire_in_sec:29Lw2p :webmedios:___cache_set:23870442_expire_in_sec:166Lw2p:webmedios: ___cache_set_expire_in_sec:Nonew2p:webmedios: ab19050d1dfd233a5191fddbad56a4ec_expire_in_sec:26L Notice the first line and the last one. Those are the stored keys, one for /demo/default/index, and the other for /fundapres/default/index. However, in production, I don't want to access applications with the appname in the url, so I map domains to apps. So, with everything working ok as shown before, now I hit the following the same two urls, but accessed in this way: http://demo.dev/default/index http://fundapres.dev/default/index Here w2p_keys has this: w2p_keys:w2p:webmedios:4c750e2df1c6be696b0d0a310fe1a6e2_expire_in_sec:27Lw2p :webmedios:___cache_set:23870452_expire_in_sec:150Lw2p:webmedios: ___cache_set_expire_in_sec:None Notice that one only one key is created (the first line), corresponding to default/index of the first hit. In this case, first hit was to demo app (throgh demo.dev domain). The second hit (to fundapres app throught fundapres.dev domain), returns the same html cached for demo app. I can "solve" this problem modifying, adding a custom prefix to the @cache.action used by each application: # for demo app @cache.action(time_expire=30, cache_model=cache.redis, session=False, vars= False, public=True, prefix='demo') # for fundapres app @cache.action(time_expire=30, cache_model=cache.redis, session=False, vars= False, public=True, prefix='fundapres') In this case, I can access default/index of both application through the corresponding domain, without having to specify appname in the url. That way it does work, and this is w2p_keys: w2p_keys:w2p:webmedios:___cache_set:23870420_expire_in_sec:170Lw2p:webmedios :___cache_set_expire_in_sec:Nonew2p:webmedios: demo4c750e2df1c6be696b0d0a310fe1a6e2_expire_in_sec:24Lw2p:webmedios: fundapres4c750e2df1c6be696b0d0a310fe1a6e2_expire_in_sec:27L As expected, the prefix specified in @cache.action is added to the key, after the "w2p:xxxxxx:" But I thought the keys would be like w2p:demo:...., w2p:fundapres:.... I've tryied to understand why the "w2p:webmedios:" is always the begining of the key, regardless the request.application is demo or fundapres. I've noticed that the "w2p:xxxxx" is generated in the "first run", using the current app. I did a flushall in redis, restarted nginx and uwsgi, and then the "w2p:xxxxx" is generated with the appname of the first run. Maybe I'm not using redis cache correctly. But I followed the documentation, very simple. from gluon.contrib.redis_cache import RedisCache cache.redis = RedisCache('localhost:6379', db=None, debug=True, with_lock= True) Again, the problem goes away if I add a prefix in @cache.action, but I think that prefix is optional and has other purpose. El jueves, 21 de mayo de 2015, 13:15:04 (UTC-3), Niphlod escribió: > > the prefix is dependant from request.application, so as long as that one > changes, I don't see how it'll be merged with another application. The keys > you have seems to point out that "demo" is the application name.... > > -- 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.