ex_limiter v0.1.0 ExLimiter.Storage behaviour View Source
Link to this section Summary
Callbacks
Consumes n elements from the bucket (atomically)
Fetch the current state of the given bucket
Set the current state of the given bucket. Specify hard if you want to force a write
Atomically update the bucket denoted by key
with fun
. Leverage whatever
concurrency controls are available in the given storage mechanism (eg cas for memcached)
Link to this section Types
Link to this type
response()
View Source
response() :: {:ok, ExLimiter.Bucket.t()} | {:error, any()}
Link to this section Callbacks
Link to this callback
consume(bucket, incr)
View Source
consume(bucket :: ExLimiter.Bucket.t(), incr :: integer()) :: {:ok, ExLimiter.Bucket.t()}
Consumes n elements from the bucket (atomically)
Link to this callback
fetch(bucket)
View Source
fetch(bucket :: ExLimiter.Bucket.t()) :: ExLimiter.Bucket.t()
Fetch the current state of the given bucket
Link to this callback
refresh(bucket)
View Source
refresh(bucket :: ExLimiter.Bucket.t()) :: response()
Set the current state of the given bucket. Specify hard if you want to force a write
Link to this callback
refresh(bucket, type)
View Source
refresh(bucket :: ExLimiter.Bucket.t(), type :: :hard | :soft) :: response()
Link to this callback
update(key, fun)
View Source
update(key :: binary(), fun :: (ExLimiter.Bucket.t() -> ExLimiter.Bucket.t())) :: ExLimiter.Bucket.t()
Atomically update the bucket denoted by key
with fun
. Leverage whatever
concurrency controls are available in the given storage mechanism (eg cas for memcached)