ShieldedCache v1.4.0 ShieldedCache.Cache.Memcached View Source

ShieldedCache.Cache.Memcached

A provided cache module that uses Memcached as the cache storage module.

Link to this section Summary

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

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, compressed \\ false) View Source
get(
  caching_module_name :: atom(),
  key :: String.t(),
  ttl :: non_neg_integer(),
  compressed :: boolean()
) ::
  {: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, compressed) View Source
get!(
  caching_module_name :: atom(),
  key :: String.t(),
  ttl :: non_neg_integer(),
  compressed :: boolean()
) :: 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 init(caching_module_name) View Source
init(caching_module_name :: atom()) :: Supervisor.on_start()

init/1

Initializes the ShieldedCache.Cache.Memcached Supervisor, which in turn starts the Memcache package under the ShieldedCache.Cache.Memcached supervision tree.

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, compressed \\ false) View Source
set(
  caching_module_name :: atom(),
  key :: String.t(),
  value :: any(),
  ttl :: non_neg_integer(),
  compressed :: boolean()
) :: :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, compressed) View Source
set!(
  caching_module_name :: atom(),
  key :: String.t(),
  value :: any(),
  ttl :: non_neg_integer(),
  compressed :: boolean()
) :: :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()) :: Supervisor.on_start()

start_link/1

Starts the ShieldedCache.Cache.Memcached Supervisor, which in turn starts the Memcache package under the ShieldedCache.Cache.Memcached 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