async def sinterstore(self, dest, keys, *args): """ Store the intersection of sets specified by ``keys`` into a new set named ``dest``. Returns the number of keys in the new set. """ args = list_or_args(keys, args) return await self.execute_command('SINTERSTORE', dest, *args)
async def sdiffstore(self, dest, keys, *args): """ Store the difference of sets specified by ``keys`` into a new set named ``dest``. Returns the number of keys in the new set. """ args = list_or_args(keys, args) return await self.execute_command('SDIFFSTORE', dest, *args)
async def unsubscribe(self, *args): """ Unsubscribes from the supplied channels. If empty, unsubscribe from all channels """ if args: args = list_or_args(args[0], args[1:]) return await self.execute_command('UNSUBSCRIBE', *args)
async def punsubscribe(self, *args): """ Unsubscribes from the supplied patterns. If empy, unsubscribe from all patterns. """ if args: args = list_or_args(args[0], args[1:]) return await self.execute_command('PUNSUBSCRIBE', *args)
async def sinter(self, keys, *args): """ Return the intersection of sets specified by ``keys`` Cluster impl: Querry all keys, intersection and return result """ k = list_or_args(keys, args) res = await self.smembers(k[0]) for arg in k[1:]: res &= await self.smembers(arg) return res
async def sdiff(self, keys, *args): """ Return the difference of sets specified by ``keys`` Cluster impl: Querry all keys and diff all sets and return result """ k = list_or_args(keys, args) res = await self.smembers(k[0]) for arg in k[1:]: res -= await self.smembers(arg) return res
async def mget(self, keys, *args): """ Returns a list of values ordered identically to ``keys`` Cluster impl: Itterate all keys and send GET for each key. This will go alot slower than a normal mget call in StrictRedis. Operation is no longer atomic. """ res = list() for arg in list_or_args(keys, args): res.append(await self.get(arg)) return res
async def sunion(self, keys, *args): """ Return the union of sets specified by ``keys`` Cluster impl: Querry all keys, union and return result Operation is no longer atomic. """ k = list_or_args(keys, args) res = await self.smembers(k[0]) for arg in k[1:]: res |= await self.smembers(arg) return res
async def subscribe(self, *args, **kwargs): """ Subscribe to channels. Channels supplied as keyword arguments expect a channel name as the key and a callable as the value. A channel's callable will be invoked automatically when a message is received on that channel rather than producing a message via ``listen()`` or ``get_message()``. """ if args: args = list_or_args(args[0], args[1:]) new_channels = {} new_channels.update(dict.fromkeys(map(self.encode, args))) for channel, handler in iteritems(kwargs): new_channels[self.encode(channel)] = handler ret_val = await self.execute_command('SUBSCRIBE', *iterkeys(new_channels)) # update the channels dict AFTER we send the command. we don't want to # subscribe twice to these channels, once for the command and again # for the reconnection. self.channels.update(new_channels) return ret_val
async def psubscribe(self, *args, **kwargs): """ Subscribes to channel patterns. Patterns supplied as keyword arguments expect a pattern name as the key and a callable as the value. A pattern's callable will be invoked automatically when a message is received on that pattern rather than producing a message via ``listen()``. """ if args: args = list_or_args(args[0], args[1:]) new_patterns = {} new_patterns.update(dict.fromkeys(map(self.encode, args))) for pattern, handler in iteritems(kwargs): new_patterns[self.encode(pattern)] = handler ret_val = await self.execute_command('PSUBSCRIBE', *iterkeys(new_patterns)) # update the patterns dict AFTER we send the command. we don't want to # subscribe twice to these patterns, once for the command and again # for the reconnection. self.patterns.update(new_patterns) return ret_val
async def sunion(self, keys, *args): "Return the union of sets specified by ``keys``" args = list_or_args(keys, args) return await self.execute_command('SUNION', *args)
async def sinter(self, keys, *args): "Return the intersection of sets specified by ``keys``" args = list_or_args(keys, args) return await self.execute_command('SINTER', *args)
async def sdiff(self, keys, *args): "Return the difference of sets specified by ``keys``" args = list_or_args(keys, args) return await self.execute_command('SDIFF', *args)
async def hmget(self, name, keys, *args): "Returns a list of values ordered identically to ``keys``" args = list_or_args(keys, args) return await self.execute_command('HMGET', name, *args)