关于STSDB4在不commit的情况下是否会对内存数据库产生影响
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using STSdb4.Database;
using System.Diagnostics;
namespace STSDB4TEST
{
class Program
{
static void Main(string[] args)
{
using (IStorageEngine engine = STSdb.FromFile("test.stsdb4"))
{
var table = engine.OpenXTable<int, Tick>("table");//new table
for(int i =0;i<100000; i++)
{
table[i] = new Tick();
}
engine.Commit();
}
Stopwatch sw = new Stopwatch();
sw.Start();
using (IStorageEngine engine = STSdb.FromFile("test.stsdb4"))
{
var table = engine.OpenXTable<int,Tick>("table");
foreach(var row in table)
{
Console.WriteLine("未清空操作……");
Console.WriteLine("{0} {1}", row.Key, row.Value);
break;
}
Console.WriteLine("清空表操作……");
table.Clear();
foreach(var row in table)
{
Console.WriteLine("{0} {1}", row.Key, row.Value);
}
Console.WriteLine("输出清空表已完成");
}
using (IStorageEngine engine = STSdb.FromFile("test.stsdb4"))
{
var table = engine.OpenXTable<int, Tick>("table");
Console.WriteLine("从新打开表输出……");
foreach(var row in table)
{
Console.WriteLine("{0} {1}", row.Key, row.Value);
Console.ReadKey();
}
}
sw.Stop();
Console.WriteLine("Console end!");
Console.WriteLine("{0}", sw.ElapsedMilliseconds);
Console.ReadKey();
}
}
public class Tick
{
public string Symbol { get; set; }
public DateTime Timestamp { get; set; }
public double Bid { get; set; }
public double Ask { get; set; }
public long Volume { get; set; }
public string Provider { get; set; }
public Tick()
{
}
}
}
输出内容:
未清空操作……
0 STSDB4TEST.Tick
清空表操作……
输出清空表已完成
从新打开表输出……
0 STSDB4TEST.Tick
综上所述,当不commit进行操作保存时,所有的操作都是不影响数据库本身的数据的
————————————————
版权声明:本文为CSDN博主「Acettest」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010178308/article/details/77878696
相关文章