Ferricstore.Commands.Set (ferricstore v0.3.4)

Copy Markdown View Source

Handles Redis set commands: SADD, SREM, SMEMBERS, SISMEMBER, SMISMEMBER, SCARD, SINTER, SUNION, SDIFF, SDIFFSTORE, SINTERSTORE, SUNIONSTORE, SINTERCARD, SRANDMEMBER, SPOP, SMOVE, SSCAN.

Each set member is stored as a compound key:

S:redis_key\0member_name -> "1"

The member name IS the Bitcask sub-key. The value is a presence marker "1". This allows O(1) membership testing via direct key lookup.

Type Enforcement

All set commands check type metadata. Using set commands on a key that holds a different type returns WRONGTYPE.

Summary

Functions

Handles a set command.

Functions

handle(cmd, args, store)

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

Handles a set command.

Parameters

  • cmd - Uppercased command name (e.g. "SADD", "SMEMBERS")
  • args - List of string arguments
  • store - Injected store map with compound key callbacks

Returns

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