wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
529 stars 75 forks source link

Does a snapshot equal to a static db? #77

Closed Morriaty-The-Murderer closed 6 years ago

Morriaty-The-Murderer commented 6 years ago

Hi

I'm using plyvel to store key-value data, which would never change if once initialized. In other words, I'd like it to be a static resource.

According to the document, a snapshot seems like what I want. But I'm confused with the following:

Long-lived snapshots may consume significant resources in your LevelDB database, since the snapshot prevents LevelDB from cleaning up old data that is still accessible by the snapshot. This means that you should never keep a snapshot around longer than necessary. The snapshot and its associated resources will be released automatically when the snapshot reference count drops to zero, which (for local variables) happens when the variable goes out of scope (or after you’ve issued a del statement). If you want explicit control over the lifetime of a snapshot, you can also clean it up yourself using Snapshot.close():

And regarding to the db files, must I keep all the xx.log LOCK LOG files?

wbolster commented 6 years ago

all your questions pertain to leveldb, not to plyvel.

do not use snapshots for this, just don't call .put() and .delete().

also never poke into the leveldb dir, it's managed by leveldb (not plyvel) and changes can corrupt data.