STSdb,最強純C#開源NoSQL和虛擬文件系統 4.0 RC2 支持C/S架構
2013-06-24 19:03 靈感之源 閱讀(5380) 評論(28) 收藏 舉報STSdb是什么
再來說明一下STSdb是什么:STSdb是C#寫的開源嵌入式數據庫和虛擬文件系統,支持實時索引,性能是同類產品的幾倍到幾十倍,訪問官方網站。
溫故知新
之前發了文章《STSdb,最強純C#開源NoSQL和虛擬文件系統》,相信大家對Waterfall-tree(瀑布樹)算法還是有興趣的。
不兼容改動
為了提供更易容的API和更好的性能,STSdb 4.0 RC2改變了文件格式,這個改變可能會持續,直到4.0正式版。
C/S架構
在上一篇文章,提及會在4.0正式版之前加入對C/S的支持,現在在RC2已經引入。
客戶端
//客戶端,創建一個連接:
using (IStorageEngine engine = STSdb.FromNetwork(host, port))
{
}
服務器端
//服務器端,啟動一個服務器實例
using (IStorageEngine engine = STSdb.FromFile("stsdb4.sys", "stsdb4.dat"))
{
var server = STSdb.CreateServer(engine, port);
server.Start();
//服務器端已經啟動,可以接受客戶端請求
server.Stop();
}
DataType類型
DataType類型用于描述非泛型的IIndex和IData數據類型
//以前的做法 XIndex<IData, IData> table = engine.OpenXIndex(typeof(Data<int>), typeof(Data<string>), "table"); //新做法 IIndex<IData, IData> table = engine.OpenXIndex(DataType.Int32, DataType.String, "table");
//以前的做法
XIndex<IData, IData> table = engine.OpenXIndex(typeof(Data<long>), typeof(Data<string, DateTime, double, double, long, string>), "table");
//新做法
DataType keyType = DataType.Int64;
DataType recordType = DataType.Slotes(
DataType.String,
DataType.DateTime,
DataType.Double,
DataType.Double,
DataType.Int64,
DataType.String
);
IIndex<IData, IData> table = engine.OpenXIndex(keyType, recordType, "table");
公有字段
IIndex現在支持公有字段的讀寫
List<T>, T[]和Dictionary
在4.0 RC2仍然不支持,但會在4.0 Final支持
下載
點擊這里下載源代碼
浙公網安備 33010602011771號