I thought I should show the case here, before submitting any issue, because 
I'm not sure if it's really a bug.

I'm using web2py with multiple apps, each app served by a specific domain. 
For this, I'm using parameter-based router, and I've set 
exclusive_domain=True (with this, the app name is removed from the url). 
All the apps have been caching in RAM some returned htmls, like this:

@cache.action(time_expire=30, cache_model=cache.ram, session=False, 
vars=False, public=True)
def index():
    ...
    return response.render()


Up to here, all good. Now, if I change to Redis, all the apps start seeing 
**the same cache**, and this is what happens: I hit the domain of the first 
app, the returned HTML is cached. If I hit any of the other domains within 
the next 30 seconds (time_expire=30), the returned HTML is the one cached 
by the first hit to the first app. It's like cache.redis isn't 
distinguishing between applications.


I was able to "solve the problem" with any of the following:
  * Adding a prefix to @cache.action, somethink like 
prefix=request.application (not a real solution, because it would be 
necessary to modify all the code where cache.action is used)
  * Explicitly including the appname in the url (neither a real solution, 
the idea is to remove the appname from url and serve it from an specific 
domain)


I looked into the file web2py/gluon/contrib/redis_cache.py, and I see this 
from the line 92 (inside the __init__ method of the RedisClient class):
        self.prefix = "w2p:%s:" % (self.request.application)
        if self.request:
            app = self.request.application
        else:
            app = ''

I also checked cache.redis.stats(), and I noticed this portion of the stats:
w2p_keys:w2p:demo:___cache_set:23870125_expire_in_sec:38L
w2p:demo:___cache_set:23870126_expire_in_sec:98L
w2p:demo:___cache_set:23870127_expire_in_sec:158L
w2p:demo:___cache_set_expire_in_sec:None
w2p:demo:f03addd369f2c5d060faf9cfae3e5c61_expire_in_sec:19L

On thing I noticed is that the key of the form "w2p:appname" shows 
**always** the name of the first installed app (excluding admin app). 
Either specifying the appname in the url or not, the key is always 
generated using the name of the first installed app. Even if I do a 
flushall in redis and hit for the first time the application X, when I 
check those stats, I see always that the key was generated using the name 
of the first installed app.

Is this the expected behaviour? 

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