1 Star 5 Fork 1

Acan / adb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.95 KB
一键复制 编辑 原始数据 按行查看 历史
沃森 提交于 2020-06-23 15:48 . 1

ADB

数据库特性:

  • 集时序(按时间快存储)、列数据库(列独立存储),热区读写(只有热区数据可以写入)特性于一体
  • 插入性能超高(单核可达 20万/s,基于 Ubuntu + AMD Ryzen5 3500U 测试环境得出)
  • 多条件查询极快(采用索引交替查询法,查询栏目越多越快)
  • LIKE模糊查询极快(直接使用二级制检索,模糊查询效率高于全等于查询)
  • 内存管理灵活,内存占用低(每个表可独立管理内存使用情况)
  • 支持zstd压缩,磁盘存储节省10倍以上
  • 采用 REST API 作为接入端,接入零成本

接入方式

Rest Api

直接通过API文档构建请求即可

socket.io

初始化连接

// 引入模块
// for browser
<script src="/socket.io/socket.io.js"></script>
// for nodejs
const io = require('socket.io-client')

// 建立连接
const client = io('http://127.0.0.1:7170')
client.on('connect', () => {
  // 连接成功
})

API

createTable(db.table, cols, opt)

初始化表结构

curl -X POST http://127.0.0.1:7170/createTable -d '{"ns": "tt.test", "cols": {}}'
client.emit('createTable', 'tt.test', {
  name: { len: 10, type: 'string', encoding: 'utf8'},
  uptime: { type: 'double'},
  test: { len: 20, type: 'string', encoding: 'utf8'},
  rand: { len: 20, type: 'string', encoding: 'utf8'},
  bool: { type: 'bool', default: false },
  int: { len: 2, type: 'int' }, // int len: 1-6, 1: 128, 2: 128 * 256, 3: 128 * 256 * 256
  time: { type: 'time' },
  date: { len: 20, type: 'string', encoding: 'utf8'}
}, { update: true })

create

插入数据

http://127.0.0.1:7170/tt.test/create?name=hehe&rand=165
test.create({
  name: 'test',
  uptime: 1.23123,
  test: 'hehedada',
  rand: '371893',
  bool: true,
  int: Acan.random(0, 99),
  time: 1592188598,
  date: '2020-06-15 10:36:56'
})

find

查询数据

http://127.0.0.1:7170/tt.test/find?name=hehe&rand[$like]=165&$limit=10&$skip=0
test.find({
  name: 'test', // 全等于查询
  test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
  rand: { $in: ['123456', '234567'] } // 数组全等于查询
}, { limit: 10, skip: 0 })

findOne

查询单条数据

http://127.0.0.1:7170/tt.test/findOne?name=hehe&rand[$like]=165&$skip=0
test.findOne({
  name: 'test', // 全等于查询
  test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
  rand: { $in: ['123456', '234567'] } // 数组全等于查询
}, { skip: 0 })

count

统计数据量

http://127.0.0.1:7170/tt.test/count?name=hehe&rand[$like]=165
test.count({
  name: 'test', // 全等于查询
  test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
  rand: { $in: ['123456', '234567'] } // 数组全等于查询
})
JavaScript
1
https://gitee.com/acans/adb.git
git@gitee.com:acans/adb.git
acans
adb
adb
master

搜索帮助