Ferricstore.Commands.Server (ferricstore v0.3.6)

Copy Markdown View Source

Handles Redis server commands: PING, ECHO, DBSIZE, KEYS, FLUSHDB, FLUSHALL, INFO, COMMAND, SELECT, LOLWUT, and DEBUG.

Each handler takes the uppercased command name, a list of string arguments, and an injected store map. Returns plain Elixir terms — the connection layer handles RESP encoding.

Supported commands

  • PING [message] — returns {:simple, "PONG"} or echoes the message
  • ECHO message — returns the message as a bulk string
  • DBSIZE — returns the number of keys in the store
  • KEYS pattern — returns keys matching a glob pattern (*, ?)
  • FLUSHDB [ASYNC|SYNC] — deletes all keys
  • FLUSHALL [ASYNC|SYNC] — alias for FLUSHDB (single-db server)
  • INFO [section] — returns server information as a bulk string
  • COMMAND — returns array of command info tuples
  • COMMAND COUNT — returns number of supported commands
  • COMMAND DOCS name — returns simplified docs for a command
  • COMMAND INFO name [name ...] — returns info for specific commands
  • COMMAND LIST — returns all command names
  • COMMAND GETKEYS command [args...] — returns which args are keys
  • SELECT db — always returns error (not supported)
  • LOLWUT [VERSION version] — returns ASCII art with FerricStore branding
  • DEBUG SLEEP seconds — sleeps for N seconds (testing only)

Summary

Functions

Handles a server command.

Functions

handle(cmd, args, store)

@spec handle(binary(), [binary()], map()) :: term()

Handles a server command.

Parameters

  • cmd - Uppercased command name (e.g. "PING", "KEYS")
  • args - List of string arguments
  • store - Injected store map with keys, dbsize, flush callbacks

Returns

Plain Elixir term: {:simple, "PONG"}, string, integer, list, :ok, or {:error, message}.