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 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
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.
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 pull echovault/sugardb
The full list of tags can be found here.
docker pull ghcr.io/echovault/sugardb
The full list of tags can be found here.
You can download the binaries by clicking on a release tag and downloading the binary for your system.
SugarDB uses RESP, which makes it compatible with existing Redis clients.
To compare command performance with Redis, benchmarks can be run with:
make benchmark
Prerequisites:
brew install redis
to run the Redis server and benchmark scriptbrew tap echovault/sugardb
&brew install echovault/echovault/sugardb
to run the SugarDB Client-Server
Benchmark script options:
make benchmark use_local_server=true
runs on your local SugarDB Client-Servermake benchmark commands=ping,set,get...
runs the benchmark script on the specified commands
- COPY
- DECR
- DECRBY
- DEL
- EXPIRE
- EXPIRETIME
- FLUSHALL
- FLUSHDB
- GET
- GETDEL
- GETEX
- INCR
- INCRBY
- INCRBYFLOAT
- MGET
- MOVE
- MSET
- OBJECTFREQ
- OBJECTIDLETIME
- PERSIST
- PEXPIRE
- PEXPIREAT
- PEXPIRETIME
- PTTL
- RANDOMKEY
- RENAME
- SET
- TTL
- TYPE
- HDEL
- HEXISTS
- HEXPIRE
- HGET
- HGETALL
- HINCRBY
- HINCRBYFLOAT
- HKEYS
- HLEN
- HMGET
- HRANDFIELD
- HSET
- HSETNX
- HSTRLEN
- HTTL
- HVALS
- SADD
- SCARD
- SDIFF
- SDIFFSTORE
- SINTER
- SINTERCARD
- SINTERSTORE
- SISMEMBER
- SMEMBERS
- SMISMEMBER
- SMOVE
- SPOP
- SRANDMEMBER
- SREM
- SUNION
- SUNIONSTORE