Commit 972e5b96 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

create a new connection if the existing connection seems dead.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28758 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 76da968c
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
Memcached based cache plugin. Memcached based cache plugin.
""" """
from thread import get_ident from thread import get_ident
from zLOG import LOG from zLOG import LOG, WARNING
from BaseCache import BaseCache from BaseCache import BaseCache
from BaseCache import CacheEntry from BaseCache import CacheEntry
from Products.ERP5Type import interfaces from Products.ERP5Type import interfaces
...@@ -77,6 +77,17 @@ class DistributedRamCache(BaseCache): ...@@ -77,6 +77,17 @@ class DistributedRamCache(BaseCache):
thread_id = get_ident() thread_id = get_ident()
memcache_conn = connection_pool.get(thread_id, None) memcache_conn = connection_pool.get(thread_id, None)
if memcache_conn is not None:
stats = memcache_conn.get_stats()
if not len(stats) or not len(stats[0][1]):
# create a new connection if the existing connection seems
# dead.
# XXX Since python-memcached does not raise an exception in such
# a case, we check here by calling get_stats(), but it will take
# a bit more time for each getCacheStorage() call.
LOG('DistributedRamCache', WARNING, 'the existing connection seems dead. a new connection will be created.')
memcache_conn.disconnect_all()
memcache_conn = None
if memcache_conn is None: if memcache_conn is None:
## we don't have memcache_conn for this thread ## we don't have memcache_conn for this thread
memcache_conn = memcache.Client(self._servers.split('\n'), memcache_conn = memcache.Client(self._servers.split('\n'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment