Coder Social home page Coder Social logo

minikv's Introduction

A KV high-performance mini-database based on memory and C++17

This project is inspired by Redis source code.

Command line tools

Developed command line tool kvctl. value type:string

yunfei@ubuntu:~/MiniKV/build$ ./kvctl --key qjx --operate set --value world --ip 43.143.229.22
+--------+
| Status |
+--------+
| OK     |
+--------+
yunfei@ubuntu:~/MiniKV/build$ ./kvctl --key qjx --operate get --ip 43.143.229.22
+-------+
| Value |
+-------+
| world |
+-------+

value type:list

yunfei@ubuntu:~/MiniKV/build$ ./kvctl --key zyf --operate set --value hello --encoding list --ip 43.143.229.22
+--------+
| Status |
+--------+
| OK     |
+--------+
yunfei@ubuntu:~/MiniKV/build$ ./kvctl --key zyf --operate set --value world --encoding list --ip 43.143.229.22
+--------+
| Status |
+--------+
| OK     |
+--------+
yunfei@ubuntu:~/MiniKV/build$ ./kvctl --key zyf --operate get --ip 43.143.229.22
+-------+
| Value |
+-------+
| hello |
| world |
+-------+

search key using regex:

yunfei@ubuntu:~/MiniKV/build$ ./kvctl --keyRex .* --operate findkey --ip 43.143.229.22
+--------+
| Key    |
+--------+
| zyf    |
| yunfei |
| qjx    |
+--------+

build

Dependencies: grpc, protobuf, gflags In the project dir, do:

cd build && cmake .. && make

then you can get kvserver and kvclient.

run

./kvserver

Persistent data frame format

avatar

Performance

Currently, no performance optimization has been done. TPS 10000+.

About

  • This project is based on the gRPC framework to implement the memory-based KV cache middleware, which realizes the client and server respectively. Support list, string type KV cache, data snapshot and progressive Rehash.

  • Communication between client and server is realized based on gRPC, and concurrency security is realized based on read-write lock; The client supports the addition, deletion, modification and query of keys.

  • Support data snapshot, background thread timing persistence, based on user-defined data frame format; Service start automaticly to read snapshot.

  • The underlying storage structure mimics the design of Redis hash table, solves hash conflicts with zipper method, and realizes automatic memory management with intelligent pointer.

  • Imitate Redis to implement the expired key based on the expired hash table, and clean up the expired key through lazy deletion.

  • Simulate the design of Redis double hash table, and implement progressive rehash after the background thread calculates the load factor regularly.

minikv's People

Contributors

zyunfeii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.