public void Reopen() { Native.leveldb_close(Database); var options = Native.leveldb_options_create(); Database = Native.leveldb_open(options, DatabasePath); Native.leveldb_get(Database, options, "key1"); }
public void Repair() { Native.leveldb_close(Database); Database = IntPtr.Zero; var options = Native.leveldb_options_create(); Native.leveldb_repair_db(options, DatabasePath); Native.leveldb_options_destroy(options); }
public void TearDown() { if (Database != IntPtr.Zero) { Native.leveldb_close(Database); } if (Directory.Exists(DatabasePath)) { Directory.Delete(DatabasePath, true); } }
public void Reopen() { Native.leveldb_close(Database); Database = IntPtr.Zero; var options = Native.leveldb_options_create(); Database = Native.leveldb_open(options, DatabasePath); var readOptions = Native.leveldb_readoptions_create(); Native.leveldb_get(Database, readOptions, "key1"); Native.leveldb_readoptions_destroy(readOptions); }
public void Cache() { Native.leveldb_close(Database); // open the DB with a cache that is not owned by LevelDB, then // close DB and then free the cache var options = Native.leveldb_options_create(); var cache = Native.leveldb_cache_create_lru((UIntPtr)64); Native.leveldb_options_set_cache(options, cache); Database = Native.leveldb_open(options, DatabasePath); Native.leveldb_close(Database); Database = IntPtr.Zero; Native.leveldb_cache_destroy(cache); }
protected virtual void Dispose(bool disposing) { var disposed = Disposed; if (disposed) { return; } Disposed = true; if (disposing) { // free managed Options = null; } // free unmanaged var handle = Handle; if (handle != IntPtr.Zero) { Handle = IntPtr.Zero; Native.leveldb_close(handle); } }