##// END OF EJS Templates
cache: allow controlling lock_auto_renewal via .ini config
super-admin -
r4719:b8138785 default
parent child Browse files
Show More
@@ -391,6 +391,8 b' rc_cache.cache_perms.expiration_time = 3'
391 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
391 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
392 #rc_cache.cache_perms.arguments.distributed_lock = true
392 #rc_cache.cache_perms.arguments.distributed_lock = true
393
393
394 ; auto-renew lock to prevent stale locks, slower but safer. Use only if problems happen
395 #rc_cache.cache_perms.arguments.lock_auto_renewal = true
394
396
395 ; ***************************************************
397 ; ***************************************************
396 ; `cache_repo` cache for file tree, Readme, RSS FEEDS
398 ; `cache_repo` cache for file tree, Readme, RSS FEEDS
@@ -414,6 +416,8 b' rc_cache.cache_repo.expiration_time = 25'
414 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
416 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
415 #rc_cache.cache_repo.arguments.distributed_lock = true
417 #rc_cache.cache_repo.arguments.distributed_lock = true
416
418
419 ; auto-renew lock to prevent stale locks, slower but safer. Use only if problems happen
420 #rc_cache.cache_repo.arguments.lock_auto_renewal = true
417
421
418 ; ##############
422 ; ##############
419 ; BEAKER SESSION
423 ; BEAKER SESSION
@@ -224,6 +224,16 b' class FileNamespaceBackend(PickleSeriali'
224
224
225
225
226 class BaseRedisBackend(redis_backend.RedisBackend):
226 class BaseRedisBackend(redis_backend.RedisBackend):
227 key_prefix = ''
228
229 def __init__(self, arguments):
230 super(BaseRedisBackend, self).__init__(arguments)
231 self._lock_timeout = self.lock_timeout
232 self._lock_auto_renewal = arguments.pop("lock_auto_renewal", False)
233
234 if self._lock_auto_renewal and not self._lock_timeout:
235 # set default timeout for auto_renewal
236 self._lock_timeout = 60
227
237
228 def _create_client(self):
238 def _create_client(self):
229 args = {}
239 args = {}
@@ -289,14 +299,8 b' class BaseRedisBackend(redis_backend.Red'
289 if self.distributed_lock:
299 if self.distributed_lock:
290 lock_key = redis_backend.u('_lock_{0}').format(key)
300 lock_key = redis_backend.u('_lock_{0}').format(key)
291 log.debug('Trying to acquire Redis lock for key %s', lock_key)
301 log.debug('Trying to acquire Redis lock for key %s', lock_key)
292
302 return get_mutex_lock(self.client, lock_key, self._lock_timeout,
293 auto_renewal = True
303 auto_renewal=self._lock_auto_renewal)
294 lock_timeout = self.lock_timeout
295 if auto_renewal and not self.lock_timeout:
296 # set default timeout for auto_renewal
297 lock_timeout = 10
298 return get_mutex_lock(self.client, lock_key, lock_timeout,
299 auto_renewal=auto_renewal)
300 else:
304 else:
301 return None
305 return None
302
306
General Comments 0
You need to be logged in to leave comments. Login now