Example #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");
        }
Example #2
0
        public void SetUp()
        {
            var tempPath = Path.GetTempPath();
            var randName = Path.GetRandomFileName();

            DatabasePath = Path.Combine(tempPath, randName);
            var options = Native.leveldb_options_create();

            Native.leveldb_options_set_create_if_missing(options, true);
            Database = Native.leveldb_open(options, DatabasePath);
        }
Example #3
0
 public DB(Options options, string path)
 {
     if (options == null)
     {
         options = new Options();
     }
     // keep a reference to options as it might contain a cache object
     // which needs to stay alive as long as the DB is not closed
     Options = options;
     Handle  = Native.leveldb_open(options.Handle, path);
 }
Example #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);
        }
Example #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);
        }
Example #6
0
 public DB(Options options, string path, System.Text.Encoding encoding)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (encoding == null)
     {
         throw new ArgumentNullException("encoding");
     }
     if (options == null)
     {
         options = new Options();
     }
     // keep a reference to options as it might contain a cache object
     // which needs to stay alive as long as the DB is not closed
     Options = options;
     Handle  = Native.leveldb_open(options.Handle, path);
 }