diff --git a/platypush/plugins/redis.py b/platypush/plugins/redis.py index 38b369d409..89eb999425 100644 --- a/platypush/plugins/redis.py +++ b/platypush/plugins/redis.py @@ -13,7 +13,12 @@ class RedisPlugin(Plugin): """ 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 def send_message(self, queue, msg, *args, **kwargs): @@ -36,6 +41,21 @@ class RedisPlugin(Plugin): redis = Redis(*args, **kwargs) 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: