Using Valkey (a Redis compatible memory data store)

Valkey is an in-memory, high performance key/value store. It’s Redis compatible which means we can use the same protocols, clients etc.

We can run up an instance via docker using

docker run --name valkey-cache -d -p 6379:6379 valkey/valkey

The valkey client can be run from the instance using

docker exec -ti valkey-cache valkey-cli

As mentioned, we can use existing tools that work with Redis, so here’s a docker-compose.yaml to run up a Valkey instance along with redis-commander

services:
  valkey:
    image: valkey/valkey
    container_name: valkey
    ports:
      - "6379:6379"

  redis-commander:
    image: rediscommander/redis-commander:latest
    container_name: redis-commander
    ports:
      - "8080:8080"
    environment:
      REDIS_HOSTS: valkey:valkey:6379

Now we can use localhost:8080 and view/interact with our data store via a browser.

valkey-cli

From the valkey-cli we can run various commands to add a key/value, get it, delete it etc.

CommandDescription
KEYS '*'List all keys
SET mykey "Hello"add/set a key/value
GET mykeyget the value for the given key
EXISTS mykeyCheck if the key exists
DEL mykeyDelete the key/value
EXPIRE mykey 60Set an expire on the key (60 seconds in this example)
TTL mykeyChecks the time to live for a key