예제 #1
0
파일: db.py 프로젝트: xdusongwei/aiorocksdb
 async def lset(self, key: str, index: int, value: bytes):
     async with self._key_lock.acquire(key):
         key_meta = await KeyMeta.find_meta(key, self)
         if key_meta and key_meta.key_type != KeyTypeEnum.LIST:
             raise ValueError(f'key {key} type is not LIST')
         async with ListCommand(key, key_meta, self) as command:
             await command.set(index, value)
예제 #2
0
파일: db.py 프로젝트: xdusongwei/aiorocksdb
 async def lindex(self, key: str, index: int):
     async with self._key_lock.acquire(key):
         key_meta = await KeyMeta.find_meta(key, self)
         if key_meta and key_meta.key_type != KeyTypeEnum.LIST:
             raise ValueError(f'key {key} type is not LIST')
         if not key_meta:
             raise ValueError(f'key {key} not exists')
         async with ListCommand(key, key_meta, self) as command:
             value = await command.index_of(index)
         return value
예제 #3
0
파일: db.py 프로젝트: xdusongwei/aiorocksdb
 async def lpush(self, key: str, value: bytes):
     async with self._key_lock.acquire(key):
         key_meta = await KeyMeta.find_meta(key, self)
         if key_meta and key_meta.key_type != KeyTypeEnum.LIST:
             raise ValueError(f'key {key} type is not LIST')
         if not key_meta:
             key_meta = KeyMeta()
             key_meta.key = key
             key_meta.key_type = KeyTypeEnum.LIST
         async with ListCommand(key, key_meta, self) as command:
             await command.insert(0, value)
예제 #4
0
파일: db.py 프로젝트: xdusongwei/aiorocksdb
 async def delete_key(self, key: str):
     async with self._key_lock.acquire(key):
         key_meta = await KeyMeta.find_meta(key, self)
         if not key_meta:
             return False
         if key_meta.key_type == KeyTypeEnum.LIST:
             async with ListCommand(key, key_meta, self) as command:
                 await command.deconstruct()
             return True
         elif key_meta.key_type == KeyTypeEnum.ORDER_LIST:
             async with SkipListCommand(key, key_meta, self) as command:
                 await command.deconstruct()
         elif key_meta.key_type == KeyTypeEnum.ORDER_LIST_SET:
             async with SkipListCommand(key, key_meta, self) as command:
                 await command.deconstruct()
         elif key_meta.key_type == KeyTypeEnum.ORDER_LIST_ZSET:
             async with SkipListCommand(key, key_meta, self) as command:
                 await command.deconstruct()
         else:
             return False