View Source Hammer.Backend.Redis (hammer_backend_redis v6.1.1)
Documentation for Hammer.Backend.Redis
This backend uses the Redix library to connect to Redis.
The backend process is started by calling start_link
:
Hammer.Backend.Redis.start_link(
expiry_ms: 60_000 * 10,
redix_config: [host: "example.com", port: 5050]
)
Options are:
expiry_ms
: Expiry time of buckets in milliseconds, used to set TTL on Redis keys. This configuration is mandatory.redix_config
: Keyword list of options to theRedix
redis client, also aliased toredis_config
redis_url
: String url of redis server to connect to (optional, invokes Redix.start_link/2)
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Record a hit in the bucket identified by key
Record a hit in the bucket identified by key
, with a custom increment
Delete all buckets associated with id
.
Retrieve information about the bucket identified by key
Callback implementation for GenServer.init/1
.
Link to this section Types
@type bucket_info() :: {key :: bucket_key(), count :: integer(), created :: integer(), updated :: integer()}
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec count_hit( pid :: pid(), key :: bucket_key(), now :: integer() ) :: {:ok, count :: integer()} | {:error, reason :: any()}
Record a hit in the bucket identified by key
@spec count_hit( pid :: pid(), key :: bucket_key(), now :: integer(), increment :: integer() ) :: {:ok, count :: integer()} | {:error, reason :: any()}
Record a hit in the bucket identified by key
, with a custom increment
@spec delete_buckets( pid :: pid(), id :: String.t() ) :: {:ok, count_deleted :: integer()} | {:error, reason :: any()}
Delete all buckets associated with id
.
@spec get_bucket( pid :: pid(), key :: bucket_key() ) :: {:ok, info :: bucket_info()} | {:ok, nil} | {:error, reason :: any()}
Retrieve information about the bucket identified by key
Callback implementation for GenServer.init/1
.