python leveldb 文档

标签(空格分隔): python leveldb


import leveldb

db = leveldb.LevelDB('./db')

db.Put('hello', 'world') 
print db.Get('hello')

db.Delete('hello') 
print db.Get('hello')

batch = leveldb.WriteBatch() 
batch.Put('hello', 'world') 
batch.Put('hello again', 'world') 
batch.Delete('hello')
db.Write(batch, sync = True)

class LevelDB(builtin.object) | LevelDB(filename, **kwargs) -> leveldb object | 
| Open a LevelDB database, from the given directory. | 
| Only the parameter filename is mandatory. | 
| filename the database directory | create_if_missing (default: True) if True, creates a new database if none exists | error_if_exists (default: False) if True, raises and error if the database already exists | paranoid_checks (default: False) if True, raises an error as soon as an internal corruption is detected | block_cache_size (default: 8 * (2 << 20)) maximum allowed size for the block cache in bytes | write_buffer_size (default 2 * (2 << 20)) 
| block_size (default: 4096) unit of transfer for the block cache in bytes | max_open_files: (default: 1000) | block_restart_interval 
| 
| Snappy compression is used, if available. | 
| Some methods support the following parameters, having these semantics: | 
| verify_checksum: iff True, the operation will check for checksum mismatches | fill_cache: iff True, the operation will fill the cache with the data read | sync: iff True, the operation will be guaranteed to sync the operation to disk | 

| Methods supported are: | 

| Get(key, verify_checksums = False, fill_cache = True): get value, raises KeyError if key not found | 

| key: the query key | 
| Put(key, value, sync = False): put key/value pair | 
| key: the key | value: the value | 
| Delete(key, sync = False): delete key/value pair, raises no error kf key not found | 

| key: the key | 
| Write(write_batch, sync = False): apply multiple put/delete operations atomatically | 
| write_batch: the WriteBatch object holding the operations | 
| RangeIter(key_from = None, key_to = None, include_value = True, verify_checksums = False, fill_cache = True): return iterator | 
| key_from: if not None: defines lower bound (inclusive) for iterator | key_to: if not None: defined upper bound (inclusive) for iterator | include_value: if True, iterator returns key/value 2-tuples, otherwise, just keys | 
| GetStats(): get a string of runtime information
class WriteBatch(builtin.object) | WriteBatch() -> write batch object | 
| Create an object, which can hold a list of database operations, which | can be applied atomically. | 
| Methods supported are: | 
| Put(key, value): add put operation to batch | 
| key: the key | value: the value | 
| Delete(key): add delete operation to batch | 
| key: the key |
'CompactRange',
 'CreateSnapshot',
 'Delete',
 'Get',
 'GetStats',
 'Put',
 'RangeIter',//通过Key进行切片处理,因为所有的存储都是有序的
 'Write',
 '__class__',
 '__delattr__',
 '__doc__',
 '__format__',
 '__getattribute__',
 '__hash__',
 '__init__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__']

转载于:https://www.cnblogs.com/bergus/p/python-leveldb-wen-dang.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值