本文整理汇总了C#中DB.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DB.Dispose方法的具体用法?C# DB.Dispose怎么用?C# DB.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreloadData
private static void PreloadData()
{
if (Directory.Exists(path))
Directory.Delete(path, true);
var options = new Options();
options.CreateIfMissing = true;
var leveldb = new DB(options, path);
var id = Guid.NewGuid().ToString();
string rowkey = "bob";
leveldb.Put("/users", "table");
leveldb.Put("/users/index/column0", "index");
leveldb.Put("/users/index/column49", "index");
for (int i = 0; i < rows; i++)
{
leveldb.Put(string.Format("/users/{0}", i), "row");
for (int x = 0; x < columns; x++)
{
leveldb.Put(string.Format("/users/{0}:column{1}", i, x), "bob" + i);
leveldb.Put(string.Format("/users/index/column{0}:{1}", x, "bob" + i),
string.Format("/users/{0}", i));
}
}
leveldb.Dispose();
Console.WriteLine(
"Rows created: " + string.Format("{0:N}", rows) +
" Columns per row: " + columns +
" Total keys in DB: " + string.Format("{0:N}", rows * columns));
}
示例2: Cache
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();
}
示例3: Main
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);
}
示例4: PurgeDB
private async Task PurgeDB(DB db, string filename)
{
db.Dispose();
await DB.PurgeAsync(filename);
}