Ferricstore.Commands.Expiry (ferricstore v0.3.7)

Copy Markdown View Source

Handles Redis expiry commands: EXPIRE, PEXPIRE, EXPIREAT, PEXPIREAT, TTL, PTTL, PERSIST.

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

  • EXPIRE key seconds — set TTL in seconds, returns 1 on success / 0 if key missing
  • PEXPIRE key milliseconds — set TTL in milliseconds
  • EXPIREAT key unix-timestamp — set absolute expiry (seconds since epoch)
  • PEXPIREAT key unix-timestamp-ms — set absolute expiry (milliseconds since epoch)
  • TTL key — remaining TTL in seconds (-1 = no expiry, -2 = key missing)
  • PTTL key — remaining TTL in milliseconds
  • PERSIST key — remove expiry, returns 1 if removed / 0 otherwise

Summary

Functions

Handles an expiry command.

Functions

handle(cmd, args, store)

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

Handles an expiry command.

Parameters

  • cmd - Uppercased command name (e.g. "EXPIRE", "TTL")
  • args - List of string arguments
  • store - Injected store map with get_meta, put callbacks

Returns

Plain Elixir term: integer or {:error, message}.