Merge pull request #2055 from erbalito/patch-1

Update redis_cache.py to allow sharing cache between applications
This commit is contained in:
mdipierro authored and GitHub committed 2018-11-18 11:06:20 -08:00
commit c52e75624c
1 file changed
+2 -2
+2 -2
View File
@@ -22,7 +22,7 @@ logger = logging.getLogger("web2py.cache.redis")
locker = Lock() locker = Lock()
def RedisCache(redis_conn=None, debug=False, with_lock=False, fail_gracefully=False, db=None): def RedisCache(redis_conn=None, debug=False, with_lock=False, fail_gracefully=False, db=None, application=None):
""" """
Usage example: put in models:: Usage example: put in models::
@@ -83,7 +83,7 @@ def RedisCache(redis_conn=None, debug=False, with_lock=False, fail_gracefully=Fa
locker.acquire() locker.acquire()
try: try:
instance_name = 'redis_instance_' + current.request.application instance_name = 'redis_instance_' + (application or current.request.application)
if not hasattr(RedisCache, instance_name): if not hasattr(RedisCache, instance_name):
setattr(RedisCache, instance_name, setattr(RedisCache, instance_name,
RedisClient(redis_conn=redis_conn, debug=debug, RedisClient(redis_conn=redis_conn, debug=debug,