Skip to content

Commit

Permalink
Merge pull request #218 from ThiefMaster/patch-1
Browse files Browse the repository at this point in the history
Fix add() in RedisCache without a timeout
  • Loading branch information
sh4nks committed Feb 17, 2021
2 parents f1899bc + 8560521 commit b5fa578
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flask_caching/backends/rediscache.py
Expand Up @@ -135,11 +135,14 @@ def set(self, key, value, timeout=None):
def add(self, key, value, timeout=None):
timeout = self._normalize_timeout(timeout)
dump = self.dump_object(value)
return self._write_client.setnx(
created = self._write_client.setnx(
name=self._get_prefix() + key, value=dump
) and self._write_client.expire(
name=self._get_prefix() + key, time=timeout
)
if created and timeout != -1:
self._write_client.expire(
name=self._get_prefix() + key, time=timeout
)
return created

def set_many(self, mapping, timeout=None):
timeout = self._normalize_timeout(timeout)
Expand Down

0 comments on commit b5fa578

Please sign in to comment.