Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _populate(self, iterable=tuple()):
encoded_values = {self._encode(value) for value in iterable}
if encoded_values:
if self.redis.exists(self.key):
raise KeyExistsError(self.redis, self.key)
else:
self.redis.multi()
self.redis.sadd(self.key, *encoded_values)
def _populate(self, iterable=tuple()):
encoded_values = [self._encode(value) for value in iterable]
if encoded_values: # pragma: no cover
if self.redis.exists(self.key):
raise KeyExistsError(self.redis, self.key)
else:
self.redis.multi()
self.redis.rpush(self.key, *encoded_values)
def __init__(self, iterable=tuple(), *, redis=None, key=None, **kwargs):
'Initialize a RedisDict. O(n)'
super().__init__(redis=redis, key=key, **kwargs)
if iterable or kwargs:
with self._watch(iterable):
if self.redis.exists(self.key):
raise KeyExistsError(self.redis, self.key)
else:
self._populate(iterable, **kwargs)