forked from platypush/platypush
Implemented mget and mset actions for Redis plugin
This commit is contained in:
parent
63890f7670
commit
cccb48c533
1 changed files with 21 additions and 1 deletions
|
@ -13,7 +13,12 @@ class RedisPlugin(Plugin):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__()
|
||||||
|
self.args = args
|
||||||
|
self.kwargs = kwargs
|
||||||
|
|
||||||
|
def _get_redis(self):
|
||||||
|
return Redis(*self.args, **self.kwargs)
|
||||||
|
|
||||||
@action
|
@action
|
||||||
def send_message(self, queue, msg, *args, **kwargs):
|
def send_message(self, queue, msg, *args, **kwargs):
|
||||||
|
@ -36,6 +41,21 @@ class RedisPlugin(Plugin):
|
||||||
redis = Redis(*args, **kwargs)
|
redis = Redis(*args, **kwargs)
|
||||||
redis.rpush(queue, msg)
|
redis.rpush(queue, msg)
|
||||||
|
|
||||||
|
@action
|
||||||
|
def mget(self, keys, *args):
|
||||||
|
"""
|
||||||
|
:returns: A list of values as specified in `keys` (wraps MGET)
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._get_redis().mget(keys, *args)[0].decode()
|
||||||
|
|
||||||
|
@action
|
||||||
|
def mset(self, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Set key/values based on mapping (wraps MSET)
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self._get_redis().mset(*args, **kwargs)
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue