SugarDB
Embeddable and distributed in-memory alternative to Redis.
Install / Use
/learn @EchoVault/SugarDBREADME
Table of Contents
<a name="what-is-sugardb"></a>
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.
<a name="features"></a>
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.
- Command extension via Lua Modules.
- Command extension via JavaScript Modules.
- 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
- JSON
- Improved Observability
<a name="usage-embedded"></a>
Usage (Embedded)
Install SugarDB with: go get github.com/echovault/sugardb/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.
<a name="usage-client-server"></a>
Usage (Client-Server)
<a name="usage-homebrew"></a>
Homebrew
To install via homebrew, run:
brew tap echovault/sugardbbrew 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"
<a name="usage-docker"></a>
Docker
docker pull echovault/sugardb
The full list of tags can be found here.
<a name="usage-container-registry"></a>
Container Registry
docker pull ghcr.io/echovault/sugardb
The full list of tags can be found here.
<a name="usage-binaries"></a>
Binaries
You can download the binaries by clicking on a release tag and downloading the binary for your system.
<a name="clients"></a>
Clients
SugarDB uses RESP, which makes it compatible with existing Redis clients.
<a name="benchmarks"></a>
Benchmarks
To compare command performance with Redis, benchmarks can be run with:
make benchmark
Prerequisites:
brew install redisto run the Redis server and benchmark scriptbrew tap echovault/sugardb&brew install echovault/echovault/sugardbto run the SugarDB Client-Server
Benchmark script options:
make benchmark use_local_server=trueruns on your local SugarDB Client-Servermake benchmark commands=ping,set,get...runs the benchmark script on the specified commands
<a name="commands"></a>
Supported Commands
<a name="commands-acl"></a>
ACL
<a name="commands-admin"></a>
ADMIN
<a name="commands-connection"></a>
CONNECTION
<a name="commands-generic"></a>
GENERIC
- COPY
- DBSIZE
- DECR
- DECRBY
- DEL
- EXISTS
- EXPIRE
- EXPIRETIME
- FLUSHALL
- FLUSHDB
- GET
- GETDEL
- GETEX
- INCR
- INCRBY
- INCRBYFLOAT
- KEYS
- MGET
- MOVE
- MSET
- OBJECTFREQ
- OBJECTIDLETIME
- PERSIST
- PEXPIRE
- PEXPIREAT
- PEXPIRETIME
- PTTL
- RANDOMKEY
- RENAME
- SET
- TTL
- TYPE
<a name="commands-hash"></a>
