コード例 #1
0
        public void WriteBatch()
        {
            var writeOptions = Native.leveldb_writeoptions_create();

            Native.leveldb_put(Database, writeOptions, "key1", "value1");

            var writeBatch = Native.leveldb_writebatch_create();

            Native.leveldb_writebatch_delete(writeBatch, "key1");
            Native.leveldb_writebatch_put(writeBatch, "key2", "value2");
            Native.leveldb_write(Database, writeOptions, writeBatch);

            var readOptions = Native.leveldb_readoptions_create();
            var value1      = Native.leveldb_get(Database, readOptions, "key1");

            Assert.IsNull(value1);
            var value2 = Native.leveldb_get(Database, readOptions, "key2");

            Assert.AreEqual("value2", value2);

            Native.leveldb_writebatch_delete(writeBatch, "key2");
            Native.leveldb_writebatch_clear(writeBatch);
            Native.leveldb_write(Database, writeOptions, writeBatch);
            value2 = Native.leveldb_get(Database, readOptions, "key2");
            Assert.AreEqual("value2", value2);

            Native.leveldb_writebatch_destroy(writeBatch);
            Native.leveldb_writeoptions_destroy(writeOptions);
            Native.leveldb_writeoptions_destroy(readOptions);
        }
コード例 #2
0
ファイル: DB.cs プロジェクト: nGenieDeveloper/BD2
 public void Write(WriteOptions writeOptions, WriteBatch writeBatch)
 {
     CheckDisposed();
     if (writeOptions == null)
     {
         writeOptions = WriteOptions.Default;
     }
     if (writeBatch == null)
     {
         throw new ArgumentNullException("writeBatch");
     }
     Native.leveldb_write(Handle, writeOptions.Handle, writeBatch.Handle);
 }