Commit ef8f47e7 authored by Nicolas Delaby's avatar Nicolas Delaby

Some chars are not allowed by memcached to build the key, so clean them up

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28902 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9148f412
...@@ -36,6 +36,7 @@ from BaseCache import BaseCache ...@@ -36,6 +36,7 @@ from BaseCache import BaseCache
from BaseCache import CacheEntry from BaseCache import CacheEntry
from Products.ERP5Type import interfaces from Products.ERP5Type import interfaces
import zope.interface import zope.interface
import string
try: try:
import memcache import memcache
...@@ -105,6 +106,8 @@ class DistributedRamCache(BaseCache): ...@@ -105,6 +106,8 @@ class DistributedRamCache(BaseCache):
## such behaviour when constructing cache_id we add scope in front ## such behaviour when constructing cache_id we add scope in front
cache_id = "%s%s%s%s" % (self._key_prefix, self._cache_plugin_path, cache_id = "%s%s%s%s" % (self._key_prefix, self._cache_plugin_path,
scope, cache_id) scope, cache_id)
#Some chars are not allowed by memcached to build the key
cache_id = cache_id.translate(string.maketrans('', ''), '[]()<>\'", ')
if self._server_max_key_length != 0: if self._server_max_key_length != 0:
## memcached will fail to store cache_id longer than MEMCACHED_SERVER_MAX_KEY_LENGTH. ## memcached will fail to store cache_id longer than MEMCACHED_SERVER_MAX_KEY_LENGTH.
return cache_id[:self._server_max_key_length] return cache_id[:self._server_max_key_length]
......
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