Esempio n. 1
0
 def smembers(self, key):
     result = set()
     if self._db.get(KEY_CODEC.encode_set(key)):
         for db_key, _ in self._get_db_iterator(
                 KEY_CODEC.get_min_set_member(key)):
             _, length, member_key = KEY_CODEC.decode_key(db_key)
             member_value = member_key[length:]
             result.add(member_value)
     return result
Esempio n. 2
0
 def _delete_db_set(self, key):
     # there are two sets of db keys for sets:
     # * set
     # * set members
     with self._db.write_batch() as batch:
         batch.delete(KEY_CODEC.encode_set(key))
         for db_key, _ in self._get_db_iterator(
                 KEY_CODEC.get_min_set_member(key)):
             batch.delete(db_key)
Esempio n. 3
0
 def smembers(self, key):
     result = set()
     key_id, length = self._get_set_key_id_and_length(key)
     if length > 0:
         for db_key, _ in self._get_db_iterator(
                 KEY_CODEC.get_min_set_member(key_id)):
             _, length, member_key = KEY_CODEC.decode_key(db_key)
             member_value = member_key[length:]
             result.add(member_value)
     return result