redisstore

package
v2.52.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redisstore adapts a go-redis client to ratelimit.Store.

It is the only place the rate limiter touches go-redis, so consumers of the ratelimit package that bring another client, or a test double, never import go-redis.

limiter, err := ratelimit.NewWithConfig(&ratelimit.Config{
	Name:  "api_request",
	Store: redisstore.New(redisClient.Redis()),
	Rules: rules,
})

Index

Constants

This section is empty.

Variables

View Source
var ErrNilClient = errors.New("redisstore: nil client")

ErrNilClient is returned by every call on a store built from a nil client.

Functions

func New

func New(client Client) ratelimit.Store

New returns a ratelimit.Store backed by client. A nil client yields a store whose calls fail with ErrNilClient, which the limiter turns into fail-open results rather than a panic at request time.

Types

type Client

type Client interface {
	goredis.Scripter
	Del(ctx context.Context, keys ...string) *goredis.IntCmd
}

Client is the go-redis surface the store needs. It is satisfied by goredis.UniversalClient, typically the labkit redis package's Client.Redis() value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL