Ferricstore.Store.ListOps (ferricstore v0.3.1)

Copy Markdown View Source

Pure-logic module for list data structure operations.

Storage format (compound key / float-position)

Each list element is stored as an individual compound key entry: L:redis_key\0{encoded_position} -> element_value

A metadata key stores length and position boundaries: LM:redis_key -> :erlang.term_to_binary({length, next_left_pos, next_right_pos})

A legacy execute/4 overload is retained for the Raft state machine.

Summary

Functions

check_string_type(value)

@spec check_string_type(binary()) :: binary() | {:error, binary()}

decode_stored(binary)

@spec decode_stored(binary() | nil) ::
  {:ok, [binary()]} | :not_found | {:error, :wrongtype}

encode_list(elements)

@spec encode_list([binary()]) :: binary()

execute(key, store, operation)

@spec execute(binary(), map(), term()) :: term()

execute(get_fn, put_fn, delete_fn, operation)

execute_lmove(src_key, dst_key, store, from_dir, to_dir)

@spec execute_lmove(binary(), binary(), map(), :left | :right, :left | :right) ::
  binary() | nil | {:error, binary()}

execute_lmove(src_get_fn, src_put_fn, src_delete_fn, dst_get_fn, dst_put_fn, from_dir, to_dir)