laitimes

The Redis in-memory database implemented in Rust was released, and the performance exploded!

The Redis in-memory database implemented in Rust was released, and the performance exploded!

overview

Rudis is a high-performance in-memory database. Rudis is a project developed in Rust to leverage the benefits of Rust to re-implement the core functionality of Redis to meet user needs for high performance, reliability, and security, while maintaining compatibility with Redis APIs.

Get started quickly

  • Splash screen
/\_____/\
    /  o   o  \          Rudis 0.0.1
   ( ==  ^  == )
    )         (          Bind: 127.0.0.1:6379
   (           )
  ( (  )   (  ) )        
 (__(__)___(__)__)
    
[2024-04-30T02:00:55Z INFO  rudis_server] Start loading appendfile
[=======================================] percent: 100% lines: 6/6 
[2024-04-30T02:00:55Z INFO  rudis_server] Server initialized
[2024-04-30T02:00:55Z INFO  rudis_server] Ready to accept connections           
  • Debugging locally
// 普通启动
cargo run

// 带参启动
cargo run -- --port 8848

// 指定配置
cargo run -- rudis.properties

// 构建程序
cargo build

cargo build --release 

cargo build --release --target=x86_64-unknown-linux-musl           

Startup parameters

  • port, default: 6379
  • save RDB 保存策略, 默认:None
  • password 密码, 默认:None
  • databases Number of databases, default: 16
  • appendfilename 持久化日志路径,默认:None
  • appendonly 开启持久化,默认:false
  • dbfilename 数据文件名,默认:dump.rdb
  • maxclients 会话上限,默认 1000
  • Hz Frequency of scheduled tasks, default 10 (times/sec)
  • dir data persistence directory, default "./"
  • bind to the host address

Operational commands

echo instruction

127.0.0.1:6379> echo helloword
helloword           

ping command

127.0.0.1:6379> ping
PONG           

set command

127.0.0.1:6379> set user bailiang
OK           

set command [expired]

127.0.0.1:6379> set user bailiang px 10000
OK
127.0.0.1:6379> set user bailiang ex 10
OK           

get 命令

127.0.0.1:6379> get user
bailiang           

from 命令

127.0.0.1:6379> del username
(integer) 1
127.0.0.1:6379> del username password
(integer) 2           

exists 命令

127.0.0.1:6379> exists user
(integer) 0           

keys 命令

127.0.0.1:6379> keys *
(empty list or set)           

auth command

127.0.0.1:6379> auth 123456
OK           

expire 命令

127.0.0.1:6379> expire user 10000
(integer) 0           

select 命令

127.0.0.1:6379> select 1
OK           

dbsize command

127.0.0.1:6379> dbsize
(integer) 2           

flushdb 命令

127.0.0.1:6379> flushdb
OK           

flushall 命令

127.0.0.1:6379> flushall
OK           

append 命令

127.0.0.1:6379> append user bailiang
(integer) 10           

move 命令

127.0.0.1:6379> move user 0
OK           

rename 命令

127.0.0.1:6379> rename username new_username
OK           

rpush 命令

127.0.0.1:6379> rpush key value1 value2
OK           

lpush command

127.0.0.1:6379> lpush key value3 value4
OK           

lion 命令

127.0.0.1:6379> llen key
(integer) 4           

A list of commands

Command Delete Appendfile Test case Document
set
get
of the
echo
flushdb
flushall
dbsize
Auth
select
curtain
exists
expire
rename
move
lpush
rpush
append
incr
decr
lindex
LPoP
rpop
lrange
ttl
pttl
type
Sadd
smembers
scard
hmset
hget
hdel
hexists
hset
keys
zadd
zscore
zcard
zcount
pexpires
mset

Performance testing

  • percent: 100% lines: 100000/100000 time: 00:00:04
  • percent: 100% lines: 200000/200000 time: 00:00:09
  • percent: 100% lines: 400000/400000 time: 00:00:19

Read on