Ferricstore.Store.Ops (ferricstore v0.4.0)

Copy Markdown View Source

Unified interface for store operations.

Dispatches based on the type of store argument:

  • %FerricStore.Instance{} struct -> calls Router directly
  • %LocalTxStore{} struct -> local ETS for same-shard, Router for remote
  • map (closure-based store) -> calls the closure

This allows incremental migration from closure maps to instance structs without changing command handler logic.

Summary

Functions

Functions

append(ctx, key, suffix)

@spec append(store(), binary(), binary()) :: {:ok, non_neg_integer()}

batch_get(ctx, keys)

@spec batch_get(store(), [binary()]) :: [binary() | nil]

batch_put(ctx, kv_pairs)

@spec batch_put(store(), [{binary(), binary()}]) :: :ok | {:error, term()}

cas(ctx, key, expected, new_val, ttl)

@spec cas(store(), binary(), binary(), binary(), non_neg_integer() | nil) ::
  1 | 0 | nil

compound_batch_delete(ctx, redis_key, compound_keys)

@spec compound_batch_delete(store(), binary(), [binary()]) :: :ok | {:error, term()}

compound_batch_get(ctx, redis_key, compound_keys)

@spec compound_batch_get(store(), binary(), [binary()]) :: [binary() | nil]

compound_batch_get_meta(ctx, redis_key, compound_keys)

@spec compound_batch_get_meta(store(), binary(), [binary()]) :: [
  {binary(), non_neg_integer()} | nil
]

compound_batch_put(ctx, redis_key, entries)

@spec compound_batch_put(store(), binary(), [{binary(), binary(), non_neg_integer()}]) ::
  :ok

compound_count(ctx, redis_key, prefix)

@spec compound_count(store(), binary(), binary()) :: non_neg_integer()

compound_delete(ctx, redis_key, compound_key)

@spec compound_delete(store(), binary(), binary()) :: :ok

compound_delete_prefix(ctx, redis_key, prefix)

@spec compound_delete_prefix(store(), binary(), binary()) :: :ok

compound_fields(ctx, redis_key, prefix)

@spec compound_fields(store(), binary(), binary()) :: [binary()]

compound_get(ctx, redis_key, compound_key)

@spec compound_get(store(), binary(), binary()) :: binary() | nil

compound_get_meta(ctx, redis_key, compound_key)

@spec compound_get_meta(store(), binary(), binary()) ::
  {binary(), non_neg_integer()} | nil

compound_put(ctx, redis_key, compound_key, value, exp)

@spec compound_put(store(), binary(), binary(), binary(), non_neg_integer()) :: :ok

compound_scan(ctx, redis_key, prefix)

@spec compound_scan(store(), binary(), binary()) :: [{binary(), binary()}]

dbsize(ctx)

@spec dbsize(store()) :: non_neg_integer()

delete(ctx, key)

@spec delete(store(), binary()) :: :ok

exists?(ctx, key)

@spec exists?(store(), binary()) :: boolean()

expire_at_ms(ctx, key)

@spec expire_at_ms(store(), binary()) :: non_neg_integer() | nil

extend(ctx, key, owner, ttl)

@spec extend(store(), binary(), binary(), pos_integer()) :: 1 | {:error, binary()}

flush(ctx)

@spec flush(store()) :: :ok | {:error, term()}

get(ctx, key)

@spec get(store(), binary()) :: binary() | nil

get_meta(ctx, key)

@spec get_meta(store(), binary()) :: {binary(), non_neg_integer()} | nil

getdel(ctx, key)

@spec getdel(store(), binary()) :: binary() | nil

getex(ctx, key, exp)

@spec getex(store(), binary(), non_neg_integer()) :: binary() | nil

getrange(ctx, key, start_idx, end_idx)

@spec getrange(store(), binary(), integer(), integer()) :: binary() | nil

getset(ctx, key, value)

@spec getset(store(), binary(), binary()) :: binary() | nil

has_compound?(store)

@spec has_compound?(store()) :: boolean()

incr(ctx, key, delta)

@spec incr(store(), binary(), integer()) :: {:ok, integer()} | {:error, binary()}

incr_float(ctx, key, delta)

@spec incr_float(store(), binary(), float()) :: {:ok, binary()} | {:error, binary()}

keys(ctx)

@spec keys(store()) :: [binary()]

list_op(ctx, key, op)

@spec list_op(store(), binary(), term()) :: term()

lock(ctx, key, owner, ttl)

@spec lock(store(), binary(), binary(), pos_integer()) :: :ok | {:error, binary()}

object_lfu(ctx, key)

@spec object_lfu(store(), binary()) :: non_neg_integer() | nil

on_push(store, key, count \\ 1)

@spec on_push(store(), binary(), non_neg_integer()) :: [pid()] | pid() | nil

prob_dir(ctx, key)

@spec prob_dir(store(), binary()) :: binary()

prob_write(ctx, command)

@spec prob_write(store(), tuple()) :: term()

put(ctx, key, value, exp)

@spec put(store(), binary(), binary(), non_neg_integer()) :: :ok | {:error, binary()}

ratelimit_add(ctx, key, window, max, count)

@spec ratelimit_add(store(), binary(), pos_integer(), pos_integer(), pos_integer()) ::
  [term()]

set(ctx, key, value, opts)

@spec set(store(), binary(), binary(), map()) :: term()

setrange(ctx, key, offset, value)

@spec setrange(store(), binary(), non_neg_integer(), binary()) ::
  {:ok, non_neg_integer()}

unlock(ctx, key, owner)

@spec unlock(store(), binary(), binary()) :: 1 | {:error, binary()}

value_size(ctx, key)

@spec value_size(store(), binary()) :: non_neg_integer() | nil

zset_member_rank(ctx, redis_key, member, reverse?)

@spec zset_member_rank(store(), binary(), binary(), boolean()) ::
  {:ok, non_neg_integer() | nil} | :unavailable

zset_rank_range(ctx, redis_key, start_idx, stop_idx, reverse?)

@spec zset_rank_range(
  store(),
  binary(),
  non_neg_integer(),
  non_neg_integer(),
  boolean()
) ::
  {:ok, [{binary(), float()}]} | :unavailable

zset_score_count(ctx, redis_key, min_bound, max_bound)

@spec zset_score_count(store(), binary(), term(), term()) ::
  {:ok, non_neg_integer()} | :unavailable

zset_score_range(ctx, redis_key, min_bound, max_bound, reverse?)

@spec zset_score_range(store(), binary(), term(), term(), boolean()) ::
  {:ok, [{binary(), float()}]} | :unavailable

zset_score_range_slice(ctx, redis_key, min_bound, max_bound, reverse?, offset, count)

@spec zset_score_range_slice(
  store(),
  binary(),
  term(),
  term(),
  boolean(),
  non_neg_integer(),
  non_neg_integer() | :all
) :: {:ok, [{binary(), float()}]} | :unavailable