Ferricstore.Commands.Strings (ferricstore v0.3.6)

Copy Markdown View Source

Handles Redis string commands.

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

  • GET key — returns the value or nil
  • SET key value [EX secs | PX ms | EXAT unix-sec | PXAT unix-ms] [NX | XX] [GET] [KEEPTTL] — sets a key with optional expiry/conditions

  • DEL key [key ...] — deletes keys, returns count deleted
  • EXISTS key [key ...] — returns count of existing keys
  • MGET key [key ...] — returns list of values (nil for missing)
  • MSET key value [key value ...] — sets multiple keys atomically
  • INCR key — increment integer value by 1
  • DECR key — decrement integer value by 1
  • INCRBY key increment — increment integer value by given amount
  • DECRBY key decrement — decrement integer value by given amount
  • INCRBYFLOAT key increment — increment float value by given amount
  • APPEND key value — append to value, return new length
  • STRLEN key — return byte length of value
  • GETSET key value — set key, return old value
  • GETDEL key — get value and delete atomically
  • GETEX key [EX s | PX ms | EXAT ts | PXAT ms-ts | PERSIST] — get and update TTL

  • SETNX key value — set if not exists
  • SETEX key seconds value — set with expiry in seconds
  • PSETEX key milliseconds value — set with expiry in milliseconds
  • GETRANGE key start end — return substring by byte range
  • SETRANGE key offset value — overwrite part of string at offset
  • MSETNX key value [key value ...] — set multiple only if none exist

Summary

Functions

Handles a string command.

Functions

handle(cmd, args, store)

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

Handles a string command.

Parameters

  • cmd - Uppercased command name (e.g. "GET", "SET")
  • args - List of string arguments
  • store - Injected store map with get, put, delete, exists? callbacks and atomic operations like incr, append, etc.

Returns

Plain Elixir term: :ok, nil, integer, string, list, or {:error, message}.