зеркало из https://github.com/mozilla/nuggets.git
add flushall and sinter
This commit is contained in:
Родитель
ce506882b6
Коммит
60a30692cb
|
@ -64,6 +64,9 @@ class MockRedis(object):
|
|||
def __init__(self):
|
||||
self.kv = StringDict()
|
||||
|
||||
def flushall(self):
|
||||
self.kv.clear()
|
||||
|
||||
def pipeline(self, **kw):
|
||||
return self
|
||||
|
||||
|
@ -109,6 +112,10 @@ class MockRedis(object):
|
|||
if isinstance(v, set):
|
||||
return v
|
||||
|
||||
def sinter(self, keys):
|
||||
sets = [self.kv.get(key, set()) for key in keys]
|
||||
return reduce(lambda x, y: x & y, sets)
|
||||
|
||||
def hmget(self, name, keys):
|
||||
db = self.kv.get(name, StringDict())
|
||||
return [db.get(key) for key in keys]
|
||||
|
|
Загрузка…
Ссылка в новой задаче