public void Cache() { Database.Dispose(); // open the DB with a cache that is not owned by LevelDB, then // close DB and then free the cache var options = new Options() { BlockCache = new Cache(64) }; Database = new DB(options, DatabasePath); options = null; GC.Collect(); Database.Put("key1", "value1"); Database.Dispose(); GC.Collect(); }
static void Main() { var l = new Logger(s => Console.WriteLine(s)); var x = new Options { CreateIfMissing = true, RestartInterval = 13, MaxOpenFiles = 100, InfoLog = l }; var db = new DB(x, @"C:\Temp\A"); db.Put("hello", "world"); var world = db.Get("hello"); Console.WriteLine(world); for (var j = 0; j < 5; j++) { var r = new Random(0); var data = ""; for (int i = 0; i < 1024; i++) { data += 'a' + r.Next(26); } for (int i = 0; i < 5 * 1024; i++) { db.Put(string.Format("row{0}", i), data); } Thread.Sleep(100); } Console.WriteLine(); //using(var logger = new Logger(Console.WriteLine)) //{ // Console.WriteLine("hello"); //} db.Dispose(); GC.KeepAlive(l); }
public void Destroy() { _db.Close(); _db.Dispose(); }