Skeg.KV (skeg v1.0.0)

Copy Markdown

Key-value commands. Keys and values are binaries, sent and returned as is.

Every function takes :timeout in ms as an option. Errors are %Skeg.Error{}; see it for what each kind proves about the request.

Summary

Functions

Deletes keys and returns how many existed.

The value under key, or nil when there is none. An empty value is "".

Adds one to the integer under key and returns the new value.

Adds delta to the integer under key and returns the new value.

The values of keys in the same order, nil where a key is missing.

Stores value under key, replacing any previous value.

Types

conn()

@type conn() :: Skeg.conn()

error()

@type error() :: {:error, Skeg.Error.t()}

Functions

delete(conn, keys, opts \\ [])

@spec delete(conn(), [binary(), ...], keyword()) :: {:ok, non_neg_integer()} | error()

Deletes keys and returns how many existed.

get(conn, key, opts \\ [])

@spec get(conn(), binary(), keyword()) :: {:ok, binary() | nil} | error()

The value under key, or nil when there is none. An empty value is "".

incr(conn, key, opts \\ [])

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

Adds one to the integer under key and returns the new value.

incr_by(conn, key, delta, opts \\ [])

@spec incr_by(conn(), binary(), integer(), keyword()) :: {:ok, integer()} | error()

Adds delta to the integer under key and returns the new value.

mget(conn, keys, opts \\ [])

@spec mget(conn(), [binary(), ...], keyword()) :: {:ok, [binary() | nil]} | error()

The values of keys in the same order, nil where a key is missing.

set(conn, key, value, opts \\ [])

@spec set(conn(), binary(), binary(), keyword()) :: :ok | error()

Stores value under key, replacing any previous value.