# ClauDB
ClauDB is a REDIS implementation in Java. At the moment is in development and only implements a small
subset of commands and features. The objetive is implement a full functional one-to-one replacement
for REDIS (2.8 branch).
You will probably wonder why I do this, the answer is I do it Just For Fun.
## Why ClauDB?
Initially I called this project TinyDB, but there's another project with the same name, so, I've
decided to chage to ClaudDB.
Clau is :key: in Valencià, a language spoken in eastern Spain, and ClauDB is a key-value database.
## Implemented commands
<details>
<summary>Server</summary>
- FLUSHDB
- INFO
- TIME
- SYNC
- SLAVEOF
- ROLE
</details>
<details>
<summary>Connection</summary>
- ECHO
- PING
- QUIT
- SELECT
</details>
<details>
<summary>Key</summary>
- DEL
- EXISTS
- KEYS
- RENAME
- TYPE
- EXPIRE
- PERSIST
- TTL
- PTTL
</details>
<details>
<summary>String</summary>
- APPEND
- DECRBY
- DECR
- GET
- GETSET
- INCRBY
- INCR
- MGET
- MSET
- MSETNX
- SET (with NX, PX, NX and XX options)
- SETEX
- SETNX
- STRLEN
</details>
<details>
<summary>Hash</summary>
- HDEL
- HEXISTS
- HGETALL
- HGET
- HKEYS
- HLEN
- HMGET
- HMSET
- HSET
- HVALS
</details>
<details>
<summary>List</summary>
- LPOP
- LPUSH
- LINDEX
- LLEN
- LRANGE
- LSET
- RPOP
- RPUSH
</details>
<details>
<summary>Set</summary>
- SADD
- SCARD
- SDIFF
- SINTER
- SISMEMBER
- SMEMBERS
- SPOP
- SRANDMEMBER
- SREM
- SUNION
</details>
<details>
<summary>Sorted Set</summary>
- ZADD
- ZCARD
- ZRANGEBYSCORE
- ZRANGE
- ZREM
- ZREVRANGE
- ZINCRBY
</details>
<details>
<summary>Pub/Sub</summary>
- SUBSCRIBE
- UNSUBSCRIBE
- PSUBSCRIBE
- PUNSUBSCRIBE
- PUBLISH
</details>
<details>
<summary>Transactions</summary>
- MULTI
- EXEC
- DISCARD
</details>
<details>
<summary>Scripting</summary>
- EVAL
- EVALSHA
- SCRIPT LOAD
- SCRIPT EXISTS
- SCRIPT FLUSH
</details>
## Design
ClauDB is implemented using Java8. Is single thread, like REDIS. It uses asynchronous IO
(netty) and reactive programing paradigm (rxjava).
Requests come from IO threads and enqueues to rxjava single thread scheduler. Then IO thread is free
to process another request. When request is done, the response is sended to client asyncronously. Then,
every request is managed one by one, in a single thread, so there's no concurrency issues to care
about.
## Features
Now only implements a subset of REDIS commands, but is usable.
~~ClauDB also supports persistence compatible with REDIS, RDB dumps and AOF journal. It can create
compatible RDB files you can load in a REDIS server.~~ Removed since 2.0 version
Now ClauDB support master/slave replication, a master can have multiple slaves, but at the moment
slaves can't have slaves.
Also implements partially the Pub/Sub subsystem.
## Changes in 2.0 version
The RDB file format support has been dropped and replaced with h2 [MVStore](http://www.h2database.com/html/mvstore.html).
This allows ClauDB to have file persistence and off heap memory support.
Another important change, now ClauDB has been splited in several subprojects:
- claudb-lib: implementation of the server and commands.
- claudb-app: command line application to run standalone server and client.
- claudb-junit4: implements a Junit4 compatible @Rule to use in junit4 based tests. [Example](https://github.com/tonivade/claudb/blob/master/junit4/src/test/java/com/github/tonivade/claudb/junit4/TestJunit4Rule.java)
- claudb-junit5: implements a Junit5 compatible extension to use in junit5 based tests. [Example](https://github.com/tonivade/claudb/blob/master/junit5/src/test/java/com/github/tonivade/claudb/junit5/TestJunit5Extension.java)
## Performance
Performance is quite good, not as good as REDIS, but it's good enough for Java.
This is ClauDB
$ redis-benchmark -t set,get -h localhost -p 7081 -n 100000 -q
SET: 82576.38 requests per second, p50=0.303 msec
GET: 93896.71 requests per second, p50=0.287 msec
And this is REDIS
$ redis-benchmark -t set,get -h localhost -p 6379 -n 100000 -q
SET: 148148.14 requests per second, p50=0.167 msec
GET: 147710.48 requests per second, p50=0.175 msec
In my laptop (Intel Core i7-1065G7, with 32G of RAM, running linux)
## BUILD
You need to clon the repo:
$ git clone https://github.com/tonivade/claudb.git
ClauDB uses Gradle as building tool, but you don't need Gradle installed, just type:
$ ./gradlew build
This scripts automatically download Gradle and then runs the tasks.
Or if you have Gradle installed, just type
$ gradle build
Create all-in-one jar
$ ./gradlew fatJar
## DOCKER
You can create your own docker images for ClauDB using the provided `Dockerfile`
$ docker build -t claudb .
And then run the image
$ docker run -p 7081:7081 claudb
## USAGE
You can start a new server listening in default port 7081.
$ wget https://repo1.maven.org/maven2/com/github/tonivade/claudb-app/2.0.1/claudb-app-2.0.1-all.jar
$ java -jar claudb-2.0.1-all.jar
or using [jgo](https://github.com/scijava/jgo) utility
$ jgo com.github.tonivade:claudb-app:2.0.1:com.github.tonivade.claudb.Server
Parameters:
Option Description
------ -----------
-N enable keyspace notifications (experimental)
-O enable off heap memory (experimental)
-P [String: file name] enable persistence (experimental) (default: ./claudb.data)
-V verbose mode
-h <String: host> define listen host (default: localhost)
--help print help
-p <Integer: port> define listen port (default: 7081)
Also you can use inside your project using Maven
<dependency>
<groupId>com.github.tonivade</groupId>
<artifactId>claudb</artifactId>
<version>2.0.1</version>
</dependency>
Or gradle
compile 'com.github.tonivade:claudb:2.0.1'
Or embed in your source code
```java
RespServer server = ClauDB.builder().host("localhost").port(7081).build();
server.start();
```
## Native Image
Now is possible to generate a native image thanks to graalvm. You can generate one with this command:
```shell
$ ./gradlew clean nativeImage
```
Some features are not available like lua runtime and offheap memory.
## TODO
- Ziplist and Maplist encoding not implemented yet.
- Master/Slave replication improvements. Slave with Slaves
- Partitioning?
- Clustering?
- Geo Commands
## Continuous Integration
[![Java CI with Gradle](https://github.com/tonivade/claudb/actions/workflows/gradle.yml/badge.svg)](https://github.com/tonivade/claudb/actions/workflows/gradle.yml)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/63af79474b40420da97b36d02972f302)](https://www.codacy.com/app/tonivade/claudb?utm_source=github.com&utm_medium=referral&utm_content=tonivade/claudb&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/63af79474b40420da97b36d02972f302)](https://www.codacy.com/app/tonivade/claudb?utm_source=github.com&utm_medium=referral&utm_content=tonivade/claudb&utm_campaign=Badge_Coverage)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.tonivade/claudb/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.tonivade/claudb)
[![Join the chat at https://gitter.im/tonivade/claudb](https://badges.gitter.im/tonivade/claudb.svg)](https://gitter.im/tonivade/claudb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Stargazers over time
[![Stargazers over time](https://starchart.cc/tonivade/claudb.svg)](https://starchart.cc/tonivade/claudb)
## LICENSE
ClauDB is released under MIT License
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
克劳DBClauDB 是 Java 中的 REDIS 实现。目前正处于开发阶段,仅实现了一小部分命令和功能。目标是实现 REDIS(2.8 分支)的全功能一对一替换。你可能会好奇我为什么这样做,答案是我只是为了好玩。为什么选择 ClauDB?最初我将这个项目命名为 TinyDB,但是有另一个项目同名,因此,我决定将其更改为 ClaudDB。Clau 在瓦伦西亚语(西班牙东部的一种语言)中是,ClauDB 是一个键值数据库。已实施的命令服务器联系钥匙细绳哈希列表放有序集合发布/订阅交易脚本设计ClauDB 使用 Java8 实现。与 REDIS 一样,是单线程的。它使用异步 IO(netty)和反应式编程范式(rxjava)。请求来自 IO 线程并排队到 rxjava 单线程调度程序。然后 IO 线程可以自由处理另一个请求。请求完成后,响应将异步发送到客户端。然后,每个请求都在单个线程中逐个管理,因此无需担心并发问题。特征现在只实现了REDIS命令的一个子集,但是可以使用。ClauDB 还支持与 REDIS、RDB 转储
资源推荐
资源详情
资源评论
收起资源包目录
ClauDB 是 Java 中的 REDIS 实现.zip (272个子文件)
gradlew.bat 3KB
Dockerfile 321B
.gitattributes 19B
.gitignore 69B
build.gradle 4KB
build.gradle 2KB
build.gradle 754B
build.gradle 272B
build.gradle 263B
settings.gradle 190B
gradlew 9KB
gradle-wrapper.jar 43KB
MVDatabase.java 10KB
ClauDB.java 10KB
DBCommandSuite.java 9KB
SortedSet.java 7KB
RDBInputStream.java 7KB
DatabaseValue.java 7KB
CommandRule.java 7KB
Database.java 6KB
InfoCommand.java 6KB
RDBOutputStreamTest.java 6KB
LuaInterpreter.java 5KB
SetCommand.java 5KB
DBCommandWrapper.java 5KB
RDBOutputStream.java 5KB
DBServerState.java 5KB
LuaInterpreterTest.java 5KB
LuaRedisBinding.java 5KB
CommandWrapperTest.java 4KB
ClauDBServerTest.java 4KB
RDBInputStreamTest.java 4KB
NashornInterpreterTest.java 4KB
SortedSetRangeByScoreCommand.java 4KB
SlaveReplication.java 4KB
DBResponseTest.java 4KB
SetCommandTest.java 4KB
Server.java 4KB
EvalCommandTest.java 4KB
MasterReplication.java 3KB
SlaveReplicationTest.java 3KB
Client.java 3KB
PatternSubscriptionSupport.java 3KB
DBConfig.java 3KB
DBResponse.java 3KB
ByteUtilsTest.java 3KB
SortedSetRangeCommandTest.java 3KB
DatabaseValueMatchers.java 3KB
NashornInterpreter.java 3KB
ExecCommandTest.java 3KB
SortedSetIncrementByCommand.java 3KB
SortedSetTest.java 3KB
SortedSetReverseRangeCommand.java 3KB
SortedSetAddCommand.java 3KB
DBCommandProcessor.java 3KB
ScriptCommands.java 3KB
SortedSetRangeCommand.java 3KB
SubscriptionSupport.java 2KB
RoleCommand.java 2KB
LuaRedisBindingTest.java 2KB
GlobPattern.java 2KB
PatternSubscribeCommandTest.java 2KB
ByteUtils.java 2KB
PublishCommandTest.java 2KB
NotificationManagerTest.java 2KB
SubscribeCommandTest.java 2KB
ScriptCommandsTest.java 2KB
DatabaseTest.java 2KB
AbstractEvalCommand.java 2KB
TypeCommandTest.java 2KB
SortedSetRangeByScoreCommandTest.java 2KB
SortedSetRemoveCommand.java 2KB
SetPopCommand.java 2KB
MultiSetIfNotExistsCommand.java 2KB
RoleCommandTest.java 2KB
ListRangeCommand.java 2KB
MasterReplicationTest.java 2KB
SetRandomMemberCommand.java 2KB
PatternUnsubscribeCommand.java 2KB
ListSetCommand.java 2KB
PatternSubscribeCommand.java 2KB
KeysCommand.java 2KB
UnsubscribeCommand.java 2KB
RightPopCommand.java 2KB
HashMultiSetCommand.java 2KB
SubscribeCommand.java 2KB
SetRemoveCommand.java 2KB
DBCommand.java 2KB
ExecCommand.java 2KB
LeftPopCommand.java 2KB
HashDeleteCommand.java 2KB
SetBitCommand.java 2KB
HashSetCommand.java 2KB
DecrementByCommand.java 2KB
IncrementByCommand.java 2KB
KeysCommandTest.java 2KB
BaseSubscriptionSupport.java 2KB
LeftPushCommand.java 2KB
RightPushCommand.java 2KB
DatabaseValueTest.java 2KB
共 272 条
- 1
- 2
- 3
资源评论
徐浪老师
- 粉丝: 8288
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功