[POC] Redis Module for TiKV

Overview

RedisTikvPoc

[POC] Redis Module for TiKV

This is a POC repository. This Redis Module will add branch new Redis commands to operate TiKV data.

After build the module you can use Redis MODULE LOAD command load it.

Build

> cargo build

Notice: If using GCC 11 you should add -include /usr/include/c++/11*/limits to CXXFLAGS.

Usage

> module load libredistikv.so
> tikv.conn 127.0.0.1:2379
> tikv.put key value
> tikv.get key
> tikv.load key
> tikv.del key
> tikv.scan prefix 10
> tikv.delrange start-key end-key
> pd.members 127.0.0.1:2379

Commands

Operate TiKV

  • tikv.conn [PDSERVERADDR] [PDSERVERADDR] ... : connect to TiKV cluster, PDSERVERADDR is optional default is 127.0.0.1:2379
  • tikv.set [KEY] [VALUE]: put a Key-Value pair into TiKV cluster.
  • tikv.get [KEY]: read a key's value from TiKV cluster.
  • tikv.del [KEY1] [KEY2] ...: delete keys from TiKV cluster.
  • tikv.load [KEY]: read a key's value from TiKV cluster and use SET command save the key-value pair into Redis memory.
  • tikv.scan [STARTKEY] [ENDKEY] [LIMIT]: scan TiKV cluster data's using given range STARTKEY to ENDKEY and return LIMIT rows. If ENDKEY is ignored the range is from STARTKEY to end.
  • tikv.delrange [STARTKEY] [ENDKEY]: use delete_range API to delete many key's from TiKV cluster.
  • tikv.mget [KEY1] [KEY2] ...: Same as Redis MGET.
  • tikv.mset [KEY1] [VALUE1] [KEY2] [VALUE2] ...: Same as Redis MSET.
  • tikv.exists [KEY1] [KEY2] ...: Same as Redis EXISTS.

Get PD API data

  • pd.members [PDSERVERADDR]: request PD to get cluster members data.

Module Parameters

module load libredistikv.so [replacesys]
  • replacesys: replace system command. If add this parameter RedisTiKV will try to add GET, SET command using TIKV.GET, TIKV.SET

Benchmark

In bench folder it contains a golang written program to do some basic performance test. As a result, read or write data from TiKV cluster will always slower than Redis SET and GET command.

As the implementation of Redis Module, it using block_client API to make it concurrency ready. So ONE operate latency will not get the top performance. And this is why benchmark for tikv serise commands is using worker pool to test in concurrency mode. As we can see if more workers in pool the better performance gets.

Replace System Commands

Change the redis.conf file, use rename-command configuration to change system command name to other name, then add replacesys parameter to MODULE LOAD command or loadmodule configuration command. For example:

redis.conf

rename-command SET OSET
rename-command GET OGET

loadmodule /usr/local/lib/libredistikv.so replacesys

Then the GET and SET command is replaced by TIKV.GET and TIKV.SET.

System Commands can be Replaced

  • SET
  • GET
  • MSET
  • MGET
  • EXISTS
  • DEL

About Key Encoding

If we not encode KEY, you can get and set any TiKV data. So this is very danger for using RedisModule with a TiKV which provide data for TiDB service. And without key encoding the module can not support multi data type such as Hash or List. So add a Key prefix is safe than without it and we can support more data type. The current key encoding format is:

$R_[DATATYPE(1Byte)]_[KEY(nByte)]

As the description it will use $R_ as fixed prefix for RedisModule used data. DATATYPE use 1 Byte to determine the data type for value. Such as Raw, Hash and etc.

Data Types may provided:

  • Raw: Raw type key, used by GET, SET series commands, use char R
  • Hash: Hash type key, used by HGET, HSET series commands, use char H
  • List: List type key, used by LPOP, LPUSH series commands, use char L

Note: Key encoding is a draft. So it may change in future.

You might also like...
A simplified version of a Redis server supporting SET/GET commands

This is a starting point for Rust solutions to the "Build Your Own Redis" Challenge. In this challenge, you'll build a toy Redis clone that's capable

An intentionally-limited Rust implementation of the Redis server with no external dependencies.

lil-redis An intentionally-limited Rust implementation of the Redis server. lil redis is an accessible implementation of a very basic Redis server (wi

Macros for redis-rs to serialize and deserialize structs automatically

redis-macros Simple macros and wrappers to redis-rs to automatically serialize and deserialize structs with serde. Installation To install it, simply

A cross-platform redis gui client

Redis-Manager A cross-platform redis gui client started developing with Tauri, React and Typescript in Vite. Get Started Prerequisites Install Node.js

📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS
📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS

Fullstack Movie Streaming Platform 📺 Netflix in RUST/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Spark, Kafka, Redis,

Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe
Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe

redi-rs (or redirs) redi-rs is a Lightweight Redis client with connection pooling written in Rust and 100% memory safe redi-rs is a Redis client writt

Simple and flexible queue implementation for Rust with support for multiple backends (Redis, RabbitMQ, SQS, etc.)

Omniqueue Omniqueue is an abstraction layer over queue backends for Rust. It includes support for RabbitMQ, Redis streams, and SQS out of the box. The

Sharded, concurrent mini redis that support http interface implemented in rust

Rudis A mini version of redis server that provides http interface implemented in Rust. The in-memorry kv-storage is sharded and concurrent safe. Inspi

Automatically publish MongoDB changes to Redis for Meteor.

changestream-to-redis Warning The project is currently in its alpha phase. There are no production loads using it yet nor any large-scale tests were c

Owner
Rain Li
Nothing is true; everything is permitted
Rain Li
A port of `java.util.*SummaryStatistics` as a Redis Module

RedisNumbersStats RedisNumbersStats is a Redis module that implements a Redis version of the Java Util *SummaryStatistics classes, such as DoubleSumma

Brian Sam-Bodden 4 Oct 4, 2022
Redis re-implemented in Rust.

rsedis Redis re-implemented in Rust. Why? To learn Rust. Use Cases rsedis does not rely on UNIX-specific features. Windows users can run it as a repla

Sebastian Waisbrot 1.6k Jan 6, 2023
Redis library for rust

redis-rs Redis-rs is a high level redis library for Rust. It provides convenient access to all Redis functionality through a very flexible but low-lev

Armin Ronacher 2.8k Jan 8, 2023
RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

Qovery 145 Nov 23, 2022
RedisJSON - a JSON data type for Redis

RedisJSON RedisJSON is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating a

null 3.4k Jan 1, 2023
A rust Key-Value store based on Redis.

Key-Value Store A Key-Value store that uses Redis to store data. Built using an async web framework in Rust with a full Command-Line interface and log

Miguel David Salcedo 0 Jan 14, 2022
Incomplete Redis client and server implementation using Tokio - for learning purposes only

mini-redis mini-redis is an incomplete, idiomatic implementation of a Redis client and server built with Tokio. The intent of this project is to provi

Tokio 2.3k Jan 4, 2023
Basic Redis Protocol specification in Rust

Basic Redis Protocol specification in Rust

Bruno 1 Jan 20, 2022
Rewrite Redis in Rust for evaluation and learning.

Drill-Redis This library has been created for the purpose of evaluating Rust functionality and performance. As such, it has not been fully tested. The

Akira Kawahara 3 Oct 18, 2022
Redis compatible server framework for Rust

Redis compatible server framework for Rust Features Create a fast custom Redis compatible server in Rust Simple API. Support for pipelining and telnet

Josh Baker 61 Nov 12, 2022