Skip to content

Commit

Permalink
Merge pull request #538 from apahomov/redis-kvstore-timeout
Browse files Browse the repository at this point in the history
Redis KV Store timeout
  • Loading branch information
camilonova committed Jul 21, 2018
2 parents 6b18e38 + dd710a4 commit 15400fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/reference/settings.rst
Expand Up @@ -191,6 +191,15 @@ The host for Redis server. Only applicable for the Redis Key Value Store
The port for Redis server. Only applicable for the Redis Key Value Store


``THUMBNAIL_REDIS_TIMEOUT``
===========================

- Default: ``3600 * 24 * 365 * 10``

Cache timeout for Redis Key Value Store in seconds. You should probably keep this
at maximum or ``None``.


``THUMBNAIL_DBM_FILE``
======================

Expand Down
1 change: 1 addition & 0 deletions sorl/thumbnail/conf/defaults.py
Expand Up @@ -40,6 +40,7 @@
THUMBNAIL_REDIS_HOST = 'localhost'
THUMBNAIL_REDIS_PORT = 6379
THUMBNAIL_REDIS_UNIX_SOCKET_PATH = None
THUMBNAIL_REDIS_TIMEOUT = 3600 * 24 * 365 * 10 # 10 years

# DBM settings
THUMBNAIL_DBM_FILE = "thumbnail_kvstore"
Expand Down
3 changes: 2 additions & 1 deletion sorl/thumbnail/kvstores/redis_kvstore.py
Expand Up @@ -24,7 +24,8 @@ def _get_raw(self, key):
return self.connection.get(key)

def _set_raw(self, key, value):
return self.connection.set(key, value)
return self.connection.set(
key, value, ex=settings.THUMBNAIL_REDIS_TIMEOUT)

def _delete_raw(self, *keys):
return self.connection.delete(*keys)
Expand Down

0 comments on commit 15400fb

Please sign in to comment.