示例#1
0
        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");
        }
示例#2
0
        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);
        }
示例#3
0
 public void TearDown()
 {
     if (Database != IntPtr.Zero)
     {
         Native.leveldb_close(Database);
     }
     if (Directory.Exists(DatabasePath))
     {
         Directory.Delete(DatabasePath, true);
     }
 }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
文件: DB.cs 项目: nGenieDeveloper/BD2
        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);
            }
        }