-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
325 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,70 @@ | ||
# Nodis | ||
|
||
![GitHub top language](https://img.shields.io/github/languages/top/diiyw/nodis) ![GitHub Release](https://img.shields.io/github/v/release/diiyw/nodis) | ||
|
||
<div class="column" align="left"> | ||
<a href="https://godoc.org/github.com/diiyw/nodis"><img src="https://godoc.org/github.com/diiyw/nodis?status.svg" /></a> | ||
<a href="https://goreportcard.com/report/github.com/diiyw/nodis"><img src="https://goreportcard.com/badge/github.com/diiyw/nodis" /></a> | ||
<a href="https://codecov.io/gh/diiyw/nodis"><img src="https://codecov.io/gh/diiyw/nodis/branch/main/graph/badge.svg?token=CupujOXpbe"/></a> | ||
</div> | ||
|
||
|
||
English | [简体中文](https://github.com/diiyw/nodis/blob/main/README_zh-cn.md) | ||
|
||
Nodis 是一个使用 Golang 编程语言实现的 Redis。这个实现提供了一种将 Redis 功能直接嵌入到应用程序中或作为独立服务器运行的简单方法。支持的命令与原始 Redis 协议兼容,允许您使用现有的 Redis 客户端(如 goredis)进行测试和集成。 | ||
|
||
## 支持的数据类型 | ||
|
||
Bitmap | ||
String | ||
List | ||
Hash | ||
Set | ||
Sorted Set | ||
|
||
## 主要特性 | ||
|
||
- **快速和可嵌入**: Golang 实现的设计目标是快速和易于嵌入到您的应用程序中。 | ||
- **低内存使用**: 该系统只在内存中存储热数据,将整体内存占用降到最低。 | ||
- **快照和 WAL 用于数据存储**: 这个 Redis 实现支持快照和预写日志(WAL)机制,用于可靠的数据存储。 | ||
- **自定义数据存储后端**: 您可以集成自定义的数据存储后端,如 Amazon S3、浏览器存储等。 | ||
使用 WebAssembly 支持浏览器: 从 1.2.0 版本开始,这个 Redis 实现可以直接在浏览器中使用 WebAssembly 运行。 | ||
使用 WebAssembly 支持浏览器: 从 1.2.0 版本开始,这个 Redis 实现可以直接在浏览器中使用 WebAssembly 运行。 | ||
- **远程变更监控**: 从 1.2.0 版本开始,该系统支持监视来自远程源的变更。 | ||
- **Redis 协议兼容性**: 从 1.5.0 版本开始,这个 Redis 实现完全支持原始的 Redis 协议,确保与现有的 Redis 客户端无缝集成。 | ||
|
||
## 支持的Redis命令 | ||
## 支持的 Redis 命令 | ||
|
||
| **Client Handling** | **Configuration** | **Key Commands** | **String Commands** | **Set Commands** | **Hash Commands** | **List Commands** | **Sorted Set Commands** | | ||
|---------------------|-----------------|-----------------|---------------------|-----------------|-----------------|------------------|----------------| | ||
| CLIENT | FLUSHALL | DEL | GET | SADD | HSET | LPUSH | ZADD | | ||
| PING | FLUSHDB | EXISTS | SET | SSCAN | HGET | RPUSH | ZCARD | | ||
| QUIT | SAVE | EXPIRE | INCR | SCARD | HDEL | LPOP | ZRANK | | ||
| ECHO | INFO | EXPIREAT | DECR | SPOP | HLEN | RPOP | ZREVRANK | | ||
| DBSIZE | | KEYS | SETBIT | SDIFF | HKEYS | LLEN | ZSCORE | | ||
| MULTI | | TTL | GETBIT | SINTER | HEXISTS | LINDEX | ZINCRBY | | ||
| DISCARD | | RENAME | INCR | SISMEMBER | HGETALL | LINSERT | ZRANGE | | ||
| EXEC | | TYPE | DESR | SMEMBERS | HINCRBY | LPUSHX | ZREVRANGE | | ||
| | | SCAN | SETEX | SREM | HICRBYFLOAT | RPUSHX | ZRANGEBYSCORE | | ||
| | | RANDOMKEY | INCRBY | SMOVE | HSETNX | LREM | ZREVRANGEBYSCORE | | ||
| | | RENAMEEX | DECRBY | SRANDMEMBER | HMGET | LSET | ZREM | | ||
| | | PERSIST | SETNX | SINTERSTORE | HMSET | LRANGE | ZREMRANGEBYRANK | | ||
| | | | INCRBYFLOAT | SUNIONSTORE | HCLEAR | LPOPRPUSH | ZREMRANGEBYSCORE | | ||
| | | | APPEND | | HSCAN | RPOPLPUSH | ZCLEAR | | ||
| | | | GETRANGE | | HVALS | BLPOP | ZEXISTS | | ||
| | | | STRLEN | | HSTRLEN | BRPOP | ZUNIONSTORE | | ||
| | | | SETRANGE | | | | ZINTERSTORE | | ||
| ------------------- | ----------------- | ---------------- | ------------------- | ---------------- | ----------------- | ----------------- | ----------------------- | | ||
| CLIENT | FLUSHALL | DEL | GET | SADD | HSET | LPUSH | ZADD | | ||
| PING | FLUSHDB | EXISTS | SET | SSCAN | HGET | RPUSH | ZCARD | | ||
| QUIT | SAVE | EXPIRE | INCR | SCARD | HDEL | LPOP | ZRANK | | ||
| ECHO | INFO | EXPIREAT | DECR | SPOP | HLEN | RPOP | ZREVRANK | | ||
| DBSIZE | | KEYS | SETBIT | SDIFF | HKEYS | LLEN | ZSCORE | | ||
| MULTI | | TTL | GETBIT | SINTER | HEXISTS | LINDEX | ZINCRBY | | ||
| DISCARD | | RENAME | INCR | SISMEMBER | HGETALL | LINSERT | ZRANGE | | ||
| EXEC | | TYPE | DESR | SMEMBERS | HINCRBY | LPUSHX | ZREVRANGE | | ||
| | | SCAN | SETEX | SREM | HICRBYFLOAT | RPUSHX | ZRANGEBYSCORE | | ||
| | | RANDOMKEY | INCRBY | SMOVE | HSETNX | LREM | ZREVRANGEBYSCORE | | ||
| | | RENAMEEX | DECRBY | SRANDMEMBER | HMGET | LSET | ZREM | | ||
| | | PERSIST | SETNX | SINTERSTORE | HMSET | LRANGE | ZREMRANGEBYRANK | | ||
| | | | INCRBYFLOAT | SUNIONSTORE | HCLEAR | LPOPRPUSH | ZREMRANGEBYSCORE | | ||
| | | | APPEND | | HSCAN | RPOPLPUSH | ZCLEAR | | ||
| | | | GETRANGE | | HVALS | BLPOP | ZEXISTS | | ||
| | | | STRLEN | | HSTRLEN | BRPOP | ZUNIONSTORE | | ||
| | | | SETRANGE | | | | ZINTERSTORE | | ||
|
||
## Get Started | ||
|
||
```bash | ||
go get github.com/diiyw/[email protected] | ||
``` | ||
|
||
Or use test version | ||
|
||
```bash | ||
go get github.com/diiyw/nodis@main | ||
``` | ||
|
||
```go | ||
package main | ||
|
||
|
@@ -66,16 +76,18 @@ func main() { | |
n := nodis.Open(opt) | ||
defer n.Close() | ||
// Set a key-value pair | ||
n.Set("key", []byte("value")) | ||
n.Set("key", []byte("value"), false) | ||
n.LPush("list", []byte("value1")) | ||
} | ||
``` | ||
|
||
## Examples | ||
|
||
<details> | ||
<summary> Watch changes</summary> | ||
|
||
Server: | ||
Server: | ||
|
||
```go | ||
package main | ||
|
||
|
@@ -106,11 +118,13 @@ func main() { | |
} | ||
} | ||
``` | ||
|
||
- Browser client built with WebAssembly | ||
|
||
```bash | ||
GOOS=js GOARCH=wasm go build -o test.wasm | ||
``` | ||
|
||
```go | ||
package main | ||
|
||
|
@@ -137,9 +151,11 @@ func main() { | |
select {} | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
## Benchmark | ||
|
||
<details> | ||
<summary>Embed benchmark</summary> | ||
Windows 11: 12C/32G | ||
|
@@ -165,7 +181,7 @@ Linux VM: 4C/8GB | |
```bash | ||
goos: linux | ||
goarch: amd64 | ||
pkg: github.com/diiyw/nodis/bench | ||
pkg: github.com/diiyw/nodis/bench | ||
BenchmarkSet-4 806912 1658 ns/op 543 B/op 7 allocs/op | ||
BenchmarkGet-4 5941904 190.6 ns/op 7 B/op 0 allocs/op | ||
BenchmarkLPush-4 852932 1757 ns/op 615 B/op 9 allocs/op | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.