redis

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package redis provides a Redis-backed ratelimit.Store using atomic Lua scripts, for distributed rate limiting across multiple instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a Redis-backed Store.

func New

func New(client redis.UniversalClient) *Store

New returns a Store backed by client.

func NewFromAddr

func NewFromAddr(addr string) *Store

NewFromAddr returns a Store backed by a client connecting to addr.

func (*Store) Close

func (s *Store) Close() error

Close implements ratelimit.Store.

func (*Store) IncrWindow

func (s *Store) IncrWindow(ctx context.Context, key string, window time.Duration) (int64, error)

IncrWindow implements ratelimit.Store.

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

Ping implements ratelimit.Store.

func (*Store) TakeTokens

func (s *Store) TakeTokens(ctx context.Context, key string, rate, burst, n int) (bool, error)

TakeTokens implements ratelimit.Store.

Jump to

Keyboard shortcuts

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