ShieldedCache v1.0.0 ShieldedCache.Cache.RedixSingleton View Source

ShieldedCache.Cache.Redix

A provided cache module that uses an already created and supervised Redix client for cache storage.

Link to this section Summary

Link to this section Functions

Link to this function deserialize(value) View Source
deserialize(value :: String.t()) ::
  {:ok, deserialized_value :: any()} | {:error, reason :: any()}

deserialize/1

The default deserializer, which uses a simple JSON Decoder to decode the value to the corresponding object.

Return {:ok, value} or {:error, reason}.

Link to this function deserialize!(value) View Source
deserialize!(value :: String.t()) :: deserialized_value :: any()

deserialize!/1

Runs the deserialize/1 function and raises an error if an error is returned.

Returns the deserialized value or raises an error.

Link to this function get(caching_module_name, key, ttl) View Source
get(caching_module_name :: atom(), key :: String.t(), ttl :: non_neg_integer()) ::
  {:ok, value :: any()}
  | {:expired, expired_value :: any()}
  | {:error, reason :: any()}

get/3

Gets the value of the specified key from the cache.

Returns {:ok, value}, {:expired, expired_value} or {:error, reason}.

Link to this function get!(caching_module_name, key, ttl) View Source
get!(caching_module_name :: atom(), key :: String.t(), ttl :: non_neg_integer()) ::
  value :: any()

get!/3

Runs the get/3 function and raises an error if an error is returned.

Returns the value or raises an error.

Link to this function invalidate(caching_module_name, key) View Source
invalidate(caching_module_name :: atom(), key :: String.t()) ::
  :ok | {:error, reason :: any()}

invalidate/2

Invalidates the value of the specified key in the cache.

Returns :ok or {:error, reason}.

Link to this function invalidate!(caching_module_name, key) View Source
invalidate!(caching_module_name :: atom(), key :: String.t()) :: :ok

invalidate!/2

Runs the invalidate/2 function and raises an error if an error is returned.

Returns :ok or raises an error.

Link to this function serialize(value) View Source
serialize(value :: any()) ::
  {:ok, serialized_value :: String.t()} | {:error, reason :: any()}

serialize/1

The default serializer, which uses a simple JSON Encoder to encode the value as a String.

Return {:ok, value} or {:error, reason}.

Link to this function serialize!(value) View Source
serialize!(value :: any()) :: value :: String.t()

serialize!/1

Runs the serialize/1 function and raises an error if an error is returned.

Returns the serialized value or raises an error.

Link to this function set(caching_module_name, key, value, ttl) View Source
set(
  caching_module_name :: atom(),
  key :: String.t(),
  value :: any(),
  ttl :: non_neg_integer()
) :: :ok | {:error, reason :: any()}

set/4

Sets the value of the specified key in the cache.

Returns :ok or {:error, reason}.

Link to this function set!(caching_module_name, key, value, ttl) View Source
set!(
  caching_module_name :: atom(),
  key :: String.t(),
  value :: any(),
  ttl :: non_neg_integer()
) :: :ok

set!/4

Runs the set/4 function and raises an error if an error is returned.

Returns the :ok or raises an error.

Link to this function start_link(opts \\ []) View Source
start_link(opts :: Keyword.t()) :: on_start :: any()

start_link/1

Starts the ShieldedCache.Cache.Redis Supervisor, which in turn starts the ShieldedCache.Cache.Redis.Pool module under the ShieldedCache.Cache.Redis supervision tree.

Link to this function ttl_seconds(ttl) View Source
ttl_seconds(ttl :: non_neg_integer()) :: float()

ttl_seconds/0

Returns the default TTL in seconds