Documentation
¶
Overview ¶
Package redislock is a Redis-backed distributed lock that satisfies lock.Provider. Opt-in: importing this package pulls in github.com/redis/go-redis/v9; the root lock package has no driver dependency.
SET NX PX <ttl_ms> for Acquire (atomic with TTL), Lua check-and-delete for Release so we only delete locks whose token we still own. This protects against a stale releaser stomping a lock that's already been reclaimed after a TTL expiry.
Index ¶
Constants ¶
const DefaultPrefix = "fc:lock"
DefaultPrefix prepended to every lock key when New is used.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is a Redis-backed implementation of lock.Provider. Pass any redis.UniversalClient — standalone, sentinel, or cluster — so consumers control connection / reconnect handling.
func New ¶
func New(client redis.UniversalClient) *Provider
New builds a provider with DefaultPrefix.
func WithPrefix ¶
func WithPrefix(client redis.UniversalClient, prefix string) *Provider
WithPrefix builds a provider that prepends prefix + ":" to every key.