Skip to content

Instantly share code, notes, and snippets.

@dw
Created May 5, 2016 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dw/4656391464195aa5da79066d48fb6d9f to your computer and use it in GitHub Desktop.
Save dw/4656391464195aa5da79066d48fb6d9f to your computer and use it in GitHub Desktop.
import lmdb
def test():
env = lmdb.open("test.lmdb", max_dbs=1, map_size=15*1024*1024)
try:
value = bytearray(" "*9*1024*1024)
with env.begin(write=True, buffers=True) as txn:
txn.put("big", value, dupdata=False, overwrite=True)
with env.begin(write=True,) as txn:
print txn.delete("big")
with env.begin(write=True,) as txn:
txn.put('a', 'a')
with env.begin(write=True, buffers=True) as txn:
txn.put("big", value, dupdata=False, overwrite=True)
with env.begin(write=True,) as txn:
print txn.delete("big")
with env.begin(write=True,) as txn:
txn.put('a', 'a')
finally:
env.sync()
env.close()
#import pdb;pdb.set_trace()
if __name__ == "__main__":
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment