ExPirate v0.1.0 ExPirate.Utils

Link to this section Summary

Functions

Returns :ttl, :expired?, :attrs or a custom property using AgentMap.Utils.get_prop/2

Link to this section Types

Link to this section Functions

Link to this function

get_prop(ep, p)
get_prop(ep(), :attrs) :: [attr()]
get_prop(ep(), :expired?) :: (item() -> boolean()) | nil
get_prop(ep(), :ttl) :: pos_integer() | nil
get_prop(ep(), custom()) :: term()

Returns :ttl, :expired?, :attrs or a custom property using AgentMap.Utils.get_prop/2.

Link to this function

set_prop(ep, prop, list)
set_prop(ep(), :expired?, (item() -> boolean()) | nil) :: ep()
set_prop(ep(), :ttl, pos_integer() | nil) :: ep()
set_prop(ep(), :attrs, [attr()]) :: ep()
set_prop(ep(), custom(), term()) :: ep()

Stores property using AgentMap.Utils.set_prop/3.

Supported :expired?, :ttl, :attrs and any custom property.

Be aware that setting :expired? deletes :ttl and vice versa.

Examples

iex> {:ok, ep} = ExPirate.start(ttl: 30)
iex> get_prop(ep, :ttl)
30
iex> ep
...> |> set_prop(:ttl, 50)
...> |> get_prop(:ttl)
50
iex> ep
...> |> set_prop(:custom, "some param")
...> |> get_prop(:custom)
"some param"
Link to this function

upd_prop(ep, prop, fun)
upd_prop(ep(), custom(), (term() -> term())) :: ep()

Update given property using AgentMap.Utils.upd_prop/3.

To change :expired?, :ttl or :attrs use set_prop/3.

Examples

iex> {:ok, ep} = ExPirate.start()
iex> ep
...> |> set_prop(:custom, 42)
...> |> upd_prop(:custom, & &1 * 2)
...> |> get_prop(:custom)
84