Skip to content

GET

GET returns the value stored under a key. Every key pins to exactly one shard via FNV-1a hashing, so the lookup touches a single shard and never crosses shard boundaries (see Architecture).

GET key

Reply: the value as a bulk string, or a null reply ($-1) when the key doesn’t exist or has expired.

> SET greeting hello
+OK
> GET greeting
$5
hello
> GET missing
$-1

The client package exposes Get:

c, _ := client.Dial("127.0.0.1:9988", 2*time.Second)
defer c.Close()
scratch := make([]byte, 4096)
val, err := c.Get([]byte("greeting"), scratch)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(val))
  • key — the key bytes.
  • scratchBuf — a reusable response buffer; it must be large enough to hold the value and is returned reused, so the caller should copy the result if it outlives the next call.
  • A missing or expired key is reported as a not-found error (no value returned), matching RESP’s null reply.
  • Wrong arity replies -ERR wrong number of arguments for 'get' command.
  • With RBAC enabled, GET is gated per key; a denial replies -NOPERM.