📚 EchoVault - Awesome Go Library for Database
Embeddable Distributed in-memory data store compatible with Redis clients.
Detailed Description of EchoVault
Table of Contents
What is SugarDB?
SugarDB is a highly configurable, distributed, in-memory data store and cache implemented in Go. It can be imported as a Go library or run as an independent service.
SugarDB aims to provide a rich set of data structures and functions for manipulating data in memory. These data structures include, but are not limited to: Lists, Sets, Sorted Sets, Hashes, and much more to come soon.
SugarDB provides a persistence layer for increased reliability. Both Append-Only files and snapshots can be used to persist data in the disk for recovery in case of unexpected shutdowns.
Replication is a core feature of SugarDB and is implemented using the RAFT algorithm, allowing you to create a fault-tolerant cluster of SugarDB nodes to improve reliability. If you do not need a replication cluster, you can always run SugarDB in standalone mode and have a fully capable single node.
SugarDB aims to not only be a server but to be importable to existing projects to enhance them with SugarDB features, this capability is always being worked on and improved.
Features
Features offered by SugarDB include:
- TLS and mTLS support for multiple server and client RootCAs.
- Replication cluster support using the RAFT algorithm.
- ACL Layer for user Authentication and Authorization.
- Distributed Pub/Sub functionality.
- Sets, Sorted Sets, Hashes, Lists and more.
- Persistence layer with Snapshots and Append-Only files.
- Key Eviction Policies.
- Command extension via shared object files.
- Command extension via embedded API.
- Multi-database support for key namespacing.
We are working hard to add more features to SugarDB to make it much more powerful. Features in the roadmap include:
- Sharding
- Streams
- Transactions
- Bitmap
- HyperLogLog
- Lua Modules
- JSON
- Improved Observability
Usage (Embedded)
Install SugarDB with: go get github.com/echovault/sugardb
.
Here's an example of using SugarDB as an embedded library. You can access all of SugarDB's commands using an ergonomic API.
func main() {
server, err := sugardb.NewSugarDB()
if err != nil {
log.Fatal(err)
}
_, _, _ = server.Set("key", "Hello, SugarDB!", sugardb.SETOptions{})
v, _ := server.Get("key")
fmt.Println(v) // Hello, SugarDB!
// (Optional): Listen for TCP connections on this SugarDB instance.
server.Start()
}
An embedded SugarDB instance can still be part of a cluster, and the changes triggered from the API will be consistent across the cluster.
Usage (Client-Server)
Homebrew
To install via homebrew, run:
brew tap echovault/sugardb
brew install echovault/echovault/sugardb
Once installed, you can run the server with the following command:
sugardb --bind-addr=localhost --data-dir="path/to/persistence/directory"
Docker
docker pull echovault/sugardb
The full list of tags can be found here.
Container Registry
docker pull ghcr.io/echovault/sugardb
The full list of tags can be found here.
Binaries
You can download the binaries by clicking on a release tag and downloading the binary for your system.
Clients
SugarDB uses RESP, which makes it compatible with existing Redis clients.
Benchmarks
The following benchmark only applies to the TCP client-server mode.
Hardware: MacBook Pro 14in, M1 chip, 16GB RAM, 8 Cores
Command: redis-benchmark -h localhost -p 7480 -q -t ping,set,get,incr,lpush,rpush,lpop,rpop,sadd,hset,zpopmin,lrange,mset
Result:
PING_INLINE: 89285.71 requests per second, p50=0.247 msec
PING_MBULK: 85543.20 requests per second, p50=0.239 msec
SET: 65573.77 requests per second, p50=0.455 msec
GET: 79176.56 requests per second, p50=0.295 msec
INCR: 68870.52 requests per second, p50=0.439 msec
LPUSH: 27601.44 requests per second, p50=1.567 msec
RPUSH: 61842.92 requests per second, p50=0.519 msec
LPOP: 58548.01 requests per second, p50=0.567 msec
RPOP: 68681.32 requests per second, p50=0.439 msec
SADD: 67613.25 requests per second, p50=0.479 msec
HSET: 56561.09 requests per second, p50=0.599 msec
ZPOPMIN: 70972.32 requests per second, p50=0.359 msec
LPUSH (needed to benchmark LRANGE): 26434.05 requests per second, p50=1.623 msec
LRANGE_100 (first 100 elements): 26939.66 requests per second, p50=1.263 msec
LRANGE_300 (first 300 elements): 5081.82 requests per second, p50=9.095 msec
LRANGE_500 (first 500 elements): 2554.87 requests per second, p50=18.191 msec
LRANGE_600 (first 600 elements): 1903.96 requests per second, p50=24.607 msec
MSET (10 keys): 56022.41 requests per second, p50=0.463 msec
Supported Commands
ACL
ADMIN
CONNECTION
GENERIC
- DECR
- DECRBY
- DEL
- EXPIRE
- EXPIRETIME
- FLUSHALL
- FLUSHDB
- GET
- INCR
- INCRBY
- MGET
- MSET
- PERSIST
- PEXPIRE
- PEXPIRETIME
- PTTL
- RENAME
- SET
- TTL
- TYPE
HASH
LIST
PUBSUB
SET
- SADD
- SCARD
- SDIFF
- SDIFFSTORE
- SINTER
- SINTERCARD
- SINTERSTORE
- SISMEMBER
- SMEMBERS
- SMISMEMBER
- SMOVE
- SPOP
- SRANDMEMBER
- SREM
- SUNION
- SUNIONSTORE
SORTED SET
- ZADD
- ZCARD
- ZCOUNT
- ZDIFF
- ZDIFFSTORE
- ZINCRBY
- ZINTER
- ZINTERSTORE
- ZLEXCOUNT
- ZMPOP
- ZMSCORE
- ZPOPMAX
- ZPOPMIN
- ZRANDMEMBER
- ZRANGE
- ZRANGESTORE
- ZRANK
- ZREM
- ZREMRANGEBYLEX
- ZREMRANGEBYRANK
- ZREMRANGEBYSCORE
- ZREVRANK
- ZSCORE
- ZUNION
- ZUNIONSTORE