-
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.
Signed-off-by: Omkar Phansopkar <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
27 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,35 +1,76 @@ | ||
|
||
# A Lite redis-server implementation in golang | ||
## A Lite redis-server implementation in golang | ||
|
||
### Prerequisites | ||
## Prerequisites | ||
- redis-cli (for testing the implementation) | ||
|
||
Installation guide - https://redis.io/docs/install/install-redis/ | ||
|
||
- Go 1.11 or later | ||
|
||
#### Setup | ||
## Try out | ||
|
||
```bash | ||
# Clone this repository | ||
$ git clone https://github.com/OmkarPh/redis-lite.git | ||
# Using brew (for mac or linux) | ||
brew install omkarph/tap/redis-server-lite | ||
redis-server-lite | ||
|
||
# or | ||
|
||
# Go into the server directory | ||
$ cd redis-lite/server/cmd | ||
# Using a release archive from https://github.com/OmkarPh/redis-server-lite/releases/latest | ||
cd ~/Downloads # Go to the Downloads folder of your machine | ||
mkdir redis-server-lite | ||
tar -xf "release_archive_file" -C redis-server-lite | ||
cd redis-server-lite | ||
./redis-server-lite | ||
|
||
# Run the server | ||
$ go run . | ||
# Test | ||
redis-cli set message Hello World | ||
redis-cli get message | ||
``` | ||
|
||
## Supported redis-cli commands | ||
|
||
| Command | Syntax | Example | | | ||
|--------- |------------------- |------------------------------ |--- | | ||
| SET | SET <key> <value> | redis-cli SET name Mark | | | ||
| GET | GET <key> | redis-cli GET name | | | ||
| INCR | INCR key | redis-cli INCR age | | | ||
| DECR | DECR key | redis-cli DECR age | | | ||
| EXISTS | EXISTS key [key ...] | redis-cli EXISTS name age | | | ||
| EXPIRE | EXPIRE key seconds | redis-cli EXPIRE name 20 | | | ||
| TTL | TTL key | redis-cli TTL key | | | ||
| DEL | DEL key [key ...] | redis-cli DEL name age | | | ||
| TYPE | TYPE key | redis-cli TYPE name | | | ||
| PING | PING | redis-cli PING | | | ||
| ECHO | ECHO <message> | redis-cli ECHO "Hello world" | | | ||
## Features | ||
|
||
- Follows RESP protocol (Works with redis-cli & redis-benchmark) | ||
- Key expiration (Active & Passive) | ||
- Simple & Sharded key-value stores | ||
|
||
Can be customised in `redis.conf` file as: | ||
``` | ||
kv_store sharded | ||
shardfactor 32 | ||
or | ||
kv_store simple | ||
``` | ||
|
||
## Supported commands | ||
|
||
Detailed documentation - https://redis.io/commands/ | ||
|
||
| Command | Syntax | Example | Description | | ||
|----------|------------------------------------------|-----------------------------------------------------------|-------------------------------------------------| | ||
| SET | SET <key> <value> | redis-cli SET name omkar | Set the string value of a key | | ||
| GET | GET <key> | redis-cli GET name | Get the value of a key | | ||
| DEL | DEL key [key ...] | redis-cli DEL name<br/>redis-cli DEL name age | Delete one or more keys | | ||
| INCR | INCR key | redis-cli INCR age | Increment the integer value of a key | | ||
| DECR | DECR key | redis-cli DECR age | Decrement the integer value of a key | | ||
| EXISTS | EXISTS key [key ...] | redis-cli EXISTS name<br/>redis-cli EXISTS name age | Check if a key exists | | ||
| EXPIRE | EXPIRE key seconds [NX / XX / GT / LT] | redis-cli EXPIRE name 20<br/>redis-cli EXPIRE name 20 NX | Set a key's time to live in seconds | | ||
| PERSIST | PERSIST key | redis-cli PERSIST name | Remove the expiration from a key | | ||
| TTL | TTL key | redis-cli TTL key | Get the time to live for a key (in seconds) | | ||
| TYPE | TYPE key | redis-cli TYPE name | Determine the type stored at a key | | ||
| PING | PING | redis-cli PING | Ping the server | | ||
| ECHO | ECHO <message> | redis-cli ECHO "Hello world" | Echo the given string | | ||
|
||
|
||
## Benchmarks | ||
|
||
```bash | ||
redis-benchmark -t SET,GET,INCR -q | ||
``` | ||
|
||
### redis-server-lite | ||
![redis-server-lite](assets/benchmarkLite.png) | ||
|
||
### Original redis-server | ||
![redis-server](assets/benchmarkOg.png) |