mono asp.net mysql_iBoxDB 高性能嵌入式数据库, 支持 Java .NET Unity Android Mono Xamarin ASP.NET Core...

iBoxDB是一款高性能的嵌入式数据库,支持多种平台,包括Java、.NET、Unity、Android、Mono、Xamarin和ASP.NET Core等。它提供了键值、文档和SQL风格的数据操作,支持LINQ和Java8 Stream,并具有自增、事务处理、数据持久化和索引等功能。与MySQL相比,iBoxDB在插入、更新和删除操作上的性能显著提高。
摘要由CSDN通过智能技术生成

示例

每个 BOX 都是一个完全隔离的独立数据空间

using(var box = db.Cube())

{

//select, insert, update, delete ...

var result = box.Commit();

}

try(Box box = db.cube()){

...

CommitResult r = box.commit();

}

普通对象操作

box["Member"].Insert(new Member() {

ID=box.NewId(),

Name = "Andy",

Password = EncodePassowrd("123")

}

);

Member m = new Member();

m.ID = box.newId();

m.setName("Kevin");

box.d("Member").insert(m);

动态列的文档数据

game["GameType"] = "ACT";

box["Product"].Insert(game);

game.put("GameType", "ACT");

box.d("Product").insert(game);

键-值风格的查询

box["Table", 2L].Select();

//支持复合键

box["Table2", 99, "ABC"].Select();

box.d("Table", 3L).select(Member.class);

//支持复合键

box.d("Table2", 88, "ABC").select(Product.class);

SQL 风格数据查询

//from TABLE where A>? & B<=? order by C limit 0,10

box.Select("from Member where Name==?", "MyName");

//from [table] where [condition]

// order by [field1] desc,[field2] limit [0,10]

//[Condition:] == != < <= > >= & | ( )

//[IFunction:] =[F1,F2,F3]

box.select(Member.class, "from Member where Name==?", "MyName");

自定义查询函数

box.Select("from Member where [Tags]", new Query("Value"));

兼容 LINQ (.NET)

from o in box.Select("from Class")

where o.Text.Contains(text)

select o;

兼容 Stream (Java8)

StreamSupport.stream(db.select("from Table").spliterator(), true)

.collect(Collectors.groupingBy((l) -> l.get("GroupID"),

Collectors.summingLong((l) -> (Long) l.get("Value"))));

更新自增

作用域

触发条件

数据类型

数据来源

主键自增

主键

插入

数字

Table Max(ID)+1

更新自增

非主键

插入/更新

长整数

Database NewId(MaxPos,1)

查询追溯

线程

用法

数据锁

阻塞

读写同一数据行

查询追溯

不阻塞

读写不同的数据行

Snapshot-Serializable 两级事务

程序区域

隔离级别

应用程序

Snapshot

数据库

Serializable

数据类型支持

.NET

JAVA

bool

char

byte

sbyte

short

ushort

int

uint

long

ulong

float

double

decimal

DateTime

Guid

bool?

char?

byte?

sbyte?

short?

ushort?

int?

uint?

long?

ulong?

float?

double?

decimal?

DateTime?

Guid?

string

//non-indexable

MemoryStream

Dictionary

boolean

Boolean

byte

Byte

char

Character

short

Short

int

Integer

long

Long

float

Float

double

Double

UUID

Date

//dynamic length

BigDecimal

BigInteger

String

//Non-Indexable

byte[]

HashMap

Object[]

数据持久层

.NET

JAVA

class BoxFileStreamConfig

class BoxMemoryStreamConfig

class ReadonlyStreamConfig

class CacheStreamConfig

class BoxFileStreamConfig

class BoxMemoryStreamConfig

class ReadonlyStreamConfig

class CacheStreamConfig

数据库路径设置

C# & JAVA,  把数据库文件放到项目工作目录外会有更好性能

iBoxDB.LocalServer.DB.Root("/data/");

ASP.NET Cross Platform

iBoxDB.LocalServer.DB.Root(MapPath("~/App_Data/"));

Xamarin

iBoxDB.LocalServer.DB.Root(System.Environment.GetFolderPath(

System.Environment.SpecialFolder.Personal));

Unity3D

iBoxDB.LocalServer.DB.Root(Application.persistentDataPath);

Android

iBoxDB.LocalServer.DB.root(android.os.Environment.getDataDirectory()

.getAbsolutePath() + "/data/" + packageName + "/");

JSP WebApplication

@WebListener()

public class StartListener implements ServletContextListener {

@Override

public void contextInitialized(ServletContextEvent sce) {

String path = System.getProperty("user.home") + "/data/";

new File(path).mkdirs();

iBoxDB.LocalServer.DB.root(path);

}

}

查询方式

//查询

box.Select("from Member");

//查询,提前加载内存, 以 '*' 开始

box.Select("*from Member");

//查询追溯, 以 '!' 开始

box.Select("!from Member")

支持索引提升查询速度

config.EnsureIndex("Member", "Field1","Field2")

config.ensureIndex(Member.class, "Member", isUnique,"Field1","Field2")

box.Select("from Member where Field1 == ? & Field2 == ?")

快速入门   C# and JAVA

using iBoxDB.LocalServer;

var db = new DB();

db.GetConfig().EnsureTable("Table", "ID");

AutoBox auto = db.Open();

auto.Insert("Table", new Record { ID = 1L, Name = "Andy" });

var o1 = auto.Get("Table", 1L);

o1.Name = "Kelly";

auto.Update("Table", o1);

auto.Delete("Table", 1L);

import iBoxDB.LocalServer.*;

DB db = new DB();

db.getConfig().ensureTable(Record.class, "Table", "ID");

AutoBox auto = db.open();

auto.insert("Table", new Record(1L, "Andy"));

Record o1 = auto.get(Record.class, "Table", 1L);

o1.Name = "Kelly";

auto.update("Table", o1);

auto.delete("Table", 1L);

安装使用

.NET: 在项目中引用 NETDB/iBoxDB.DLL

Java: 在项目中引用 JavaDB/iBoxDB.jar

与 MySQL 的性能参照

iBoxDB

Insert: 1,000,000 AVG: 47,016 objects/s

Update: 1,000,000 AVG: 25,558 objects/s

Delete: 1,000,000 AVG: 42,714 objects/s

MySQL

Insert: 1,000,000 AVG: 5,514 objects/s

Update: 1,000,000 AVG: 5,109 objects/s

Delete: 1,000,000 AVG: 6,044 objects/s

复合键支持

55bb1186b4d6c0997fa838c06031f7e4.png

config.ensureTable(Item.class, "Item", "UID", "Type")

数据库同步,主从与多主

65deb22c7ccf241b1ea963aa33e37247.png

7f3fa418a87bc67f55fadcdeefb5dbaa.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值