This guide walks you through running HelixDB and using it to store, retrieve, and expire data.
Clone the repository and run:
git clone https://github.com/cankush625/HelixDB.git
cd HelixDB
go run .Or build a binary:
go build -o helixdb .
./helixdbThe server starts on port 6378.
HelixDB speaks RESP, so you can connect using redis-cli:
redis-cli -p 6378Or with netcat for raw access:
nc localhost 6378A native HelixDB CLI is on the roadmap. For now,
redis-cliis the recommended client.
Once connected, verify the server is up:
> PING
PONG
Store a value with SET and retrieve it with GET:
> SET name helix
OK
> GET name
helix
If you try to get a key that doesn't exist, you get nil back:
> GET nonexistent
nil
You can store a key with a TTL so it automatically disappears after a given time.
Set a key that expires in 60 seconds:
> SET session abc123 EX 60
OK
Or in milliseconds:
> SET token xyz PX 5000
OK
You can also set expiry on a key that already exists using EXPIRE:
> SET greeting hello
OK
> EXPIRE greeting 10
1
A return value of 1 means the TTL was set. 0 means the key didn't exist.
Once a key expires, GET returns nil:
> GET session
nil
Delete one or more keys with DEL:
> SET a 1
OK
> SET b 2
OK
> DEL a b
2
The return value is the number of keys actually deleted. Keys that don't exist are ignored:
> DEL nonexistent
0
Use KEYS to list keys matching a pattern:
> SET user:1 alice
OK
> SET user:2 bob
OK
> KEYS user:*
user:1
user:2
> KEYS *
user:1
user:2
See the KEYS doc for supported pattern syntax.
Note:
KEYSscans the entire store. Use it for debugging, not in hot paths.