Esempio n. 1
0
 def test_list_or_args(self):
     bfoo = b('foo')
     ufoo = u('foo')
     # first record is a text instance
     self.assertEquals(list_or_args(ufoo, []), [ufoo])
     self.assertEquals(list_or_args(ufoo, [ufoo]), [ufoo, ufoo])
     # first record is a list
     self.assertEquals(list_or_args([ufoo], [ufoo]), [ufoo, ufoo])
     # first record is a binary instance
     self.assertEquals(list_or_args(bfoo, []), [bfoo])
     self.assertEquals(list_or_args(bfoo, [bfoo]), [bfoo, bfoo])
Esempio n. 2
0
 def test_list_or_args(self):
     bfoo = b('foo')
     ufoo = u('foo')
     # first record is a text instance
     self.assertEquals(list_or_args(ufoo, []), [ufoo])
     self.assertEquals(list_or_args(ufoo, [ufoo]), [ufoo, ufoo])
     # first record is a list
     self.assertEquals(list_or_args([ufoo], [ufoo]), [ufoo, ufoo])
     # first record is a binary instance
     self.assertEquals(list_or_args(bfoo, []), [bfoo])
     self.assertEquals(list_or_args(bfoo, [bfoo]), [bfoo, bfoo])
Esempio n. 3
0
 def mget(self, keys, *args):
     args = list_or_args(keys, args)
     commands = []
     for arg in args:
         commands.append(('MGET', arg))
     results = self._execute_multi_command_with_poller('MGET', commands)
     return [results[k] for k in args]
Esempio n. 4
0
 def mget(self, keys, *args):
     args = list_or_args(keys, args)
     commands = []
     for arg in args:
         commands.append(('MGET', arg))
     results = self._execute_multi_command_with_poller('MGET', commands)
     return [results[k] for k in args]
    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.
                      This method is no longer atomic.
        """
        return [self.get(arg) for arg in list_or_args(keys, args)]
Esempio n. 6
0
 def _rc_mget(self, keys, *args):
     """
     Returns a list of values ordered identically to ``*args``
     """
     args = list_or_args(keys, args)
     result = []
     for key in args:
         result.append(self.get(key))
     return result
Esempio n. 7
0
    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.
                      This method is no longer atomic.
        """
        return [self.get(arg) for arg in list_or_args(keys, args)]
Esempio n. 8
0
 def _rc_mget(self, keys, *args):
     """
     Returns a list of values ordered identically to ``*args``
     """
     args = list_or_args(keys, args)
     result = []
     for key in args:
         result.append(self.get(key))
     return result
Esempio n. 9
0
 def _rc_sunionstore(self, dst, src, *args):
     """
     Store the union of sets ``src``,  ``args`` into a new
     set named ``dest``.  Returns the number of keys in the new set.
     """
     args = list_or_args(src, args)
     result = self.sunion(*args)
     if result is not set([]):
         return self.sadd(dst, *list(result))
     return 0
Esempio n. 10
0
 def _rc_sunionstore(self, dst, src, *args):
     """
     Store the union of sets ``src``,  ``args`` into a new
     set named ``dest``.  Returns the number of keys in the new set.
     """
     args = list_or_args(src, args)
     result = self.sunion(*args)
     if result is not set([]):
         return self.sadd(dst, *list(result))
     return 0
    def sunion(self, keys, *args):
        """
        Return the union of sets specified by ``keys``

        Cluster impl: Querry all keys, union and return result
        """
        k = list_or_args(keys, args)
        res = self.smembers(k[0])
        for arg in k[1:]:
            res = res | self.smembers(arg)
        return res
    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 = self.smembers(k[0])
        for arg in k[1:]:
            res = res - self.smembers(arg)
        return res
Esempio n. 13
0
 def _rc_sunion(self, src, *args):
     """
     Returns the members of the set resulting from the union between
     the first set and all the successive sets.
     """
     args = list_or_args(src, args)
     src_set = self.smembers(args.pop(0))
     if src_set is not set([]):
         for key in args:
             src_set.update(self.smembers(key))
     return src_set
Esempio n. 14
0
    def sunion(self, keys, *args):
        """
        Return the union of sets specified by ``keys``

        Cluster impl: Querry all keys, union and return result
        """
        k = list_or_args(keys, args)
        res = self.smembers(k[0])
        for arg in k[1:]:
            res = res | self.smembers(arg)
        return res
Esempio n. 15
0
 def _rc_sunion(self, src, *args):
     """
     Returns the members of the set resulting from the union between
     the first set and all the successive sets.
     """
     args = list_or_args(src, args)
     src_set = self.smembers(args.pop(0))
     if src_set is not set([]):
         for key in args:
             src_set.update(self.smembers(key))
     return src_set
Esempio n. 16
0
    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 = self.smembers(k[0])
        for arg in k[1:]:
            res = res - self.smembers(arg)
        return res
Esempio n. 17
0
        def _sinter(keys, *args):
            with self._lock.writer():
                keys = list_or_args(keys, args)
                sets = [self._assert_set(self._cache.get(self._to_str(key), None)) for key in keys]

                if sets:
                    i = sets[0]
                    for s in sets[1:]:
                        i = i.intersection(s)
                    return i
                else:
                    return set()
Esempio n. 18
0
 def sunionstore(self, dest, keys, *args):
     keys = list_or_args(keys, args)
     return super().sunion(self.make_key(dest), self.make_keys(keys))
Esempio n. 19
0
 def execute(self, command, params=()):
     try:
         args = list_or_args(command, params)
         return self.cursor.execute_command(*args)
     except RedisError as e:
         raise  utils.DatabaseError(*tuple(e))
Esempio n. 20
0
 def mget(self, keys, *args):
     args = list_or_args(keys, args)
     return Promise.all([self.get(arg) for arg in args])
Esempio n. 21
0
 def assert_not_in_reserved_namespace(names, *args):
     names = list_or_args(names, args)
     if any(RedizConventions.sep() in name for name in names):
         raise Exception("Operation attempted with a name that uses " +
                         RedizConventions.sep())
Esempio n. 22
0
 def sunion(self, keys, *args):
     keys = list_or_args(keys, args)
     return super().sunion(self.make_keys(keys))
Esempio n. 23
0
 def mget(self, keys, *args):
     args = list_or_args(keys, args)
     return Promise.all([self.get(arg) for arg in args])
Esempio n. 24
0
 def hmget(self, name, keys, *args):
     keys = list_or_args(keys, args)
     return super().hmget(self.make_key(name), self.make_keys(keys))