Packages
ferricstore
0.8.0
0.11.14
0.11.12
0.11.11
0.11.10
0.11.9
0.11.8
0.11.7
0.11.6
0.11.5
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.3
0.10.2
0.10.1
0.10.0
0.9.1
0.9.0
0.8.0
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.2.0
0.1.0
FerricFlow durable workflows and queues with native-protocol storage, Raft durability, and Bitcask persistence.
Current section
Files
Jump to
Current section
Files
lib/ferricstore/commands/stream/cache_key.ex
defmodule Ferricstore.Commands.Stream.CacheKey do
@moduledoc false
alias Ferricstore.Store.LocalTxStore
@type scope :: term()
@type t :: binary() | {scope(), binary()}
@spec build(term(), binary()) :: t()
def build(%FerricStore.Instance{name: name}, key) when is_binary(key), do: {name, key}
def build(%LocalTxStore{instance_ctx: instance_ctx}, key), do: build(instance_ctx, key)
def build(%{instance_ctx: %FerricStore.Instance{} = instance_ctx}, key),
do: build(instance_ctx, key)
def build(%{cache_scope: scope}, key) when is_binary(key), do: {scope, key}
def build(_store, key) when is_binary(key), do: key
@spec raw(term()) :: binary() | nil
def raw({_scope, key}) when is_binary(key), do: key
def raw(key) when is_binary(key), do: key
def raw(_invalid), do: nil
@spec scope(term()) :: {:ok, scope()} | :unscoped
def scope(%FerricStore.Instance{name: name}), do: {:ok, name}
def scope(%LocalTxStore{instance_ctx: instance_ctx}), do: scope(instance_ctx)
def scope(%{instance_ctx: %FerricStore.Instance{} = instance_ctx}),
do: scope(instance_ctx)
def scope(%{cache_scope: scope}), do: {:ok, scope}
def scope(_store), do: :unscoped
@spec in_scope?(t(), scope()) :: boolean()
def in_scope?({scope, key}, scope) when is_binary(key), do: true
def in_scope?(_cache_key, _scope), do: false
end