CounterEx v0.1.0 CounterEx View Source

Documentation for CounterEx.

Link to this section Summary

Functions

Returns all the counters as list ex. [{key, value}....{key, value}]

Returns the value of the counter or nil

Create/Update the counter by 1 (default) or custom step. Returns the new value

Reset the value of a counter to 0 or custom step

Set the value of a counter to 0 or custom step

Link to this section Functions

Returns all the counters as list ex. [{key, value}....{key, value}]

Examples

iex> CounterEx.all
nil
iex> CounterEx.inc("sample.key") && CounterEx.all
[{"sample.key", 1}]
Link to this function

benchmark(parallel \\ 2)

View Source

Returns the value of the counter or nil

Examples

iex> CounterEx.get("sample.key")
nil
iex> CounterEx.inc("sample.key") && CounterEx.get("sample.key")
1
Link to this function

inc(key, step \\ 1, default \\ 0)

View Source

Create/Update the counter by 1 (default) or custom step. Returns the new value

Examples

iex> CounterEx.inc("sample.key")
1
iex> CounterEx.inc("sample.key")
2
iex> CounterEx.inc(:sample_key)
1
Link to this function

reset(key, initial_value \\ 0)

View Source

Reset the value of a counter to 0 or custom step

Examples

iex> CounterEx.reset("test.key")
true
Link to this function

set(key, value \\ 0)

View Source
set(binary(), integer()) :: boolean()

Set the value of a counter to 0 or custom step

Examples

iex> CounterEx.set("test.key")
true
Link to this function

start_keeper()

View Source
start_keeper() :: {CounterEx.Keeper, []}
Link to this function

start_keeper_with_sweep(interval)

View Source
start_keeper_with_sweep(integer()) ::
  {CounterEx.Keeper, [{:interval, integer()}, ...]}