storage

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStorage

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

MemoryStorage is an in-memory rate limit storage implementation

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

func (*MemoryStorage) Increment

func (m *MemoryStorage) Increment(ctx context.Context, key string, window time.Duration) (int, error)

type RedisStorage

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

RedisStorage implements rl.Storage using Redis counters with windowed expiry.

func NewRedisStorage

func NewRedisStorage(client *redis.Client) *RedisStorage

NewRedisStorage creates a new RedisStorage.

func (*RedisStorage) Increment

func (s *RedisStorage) Increment(ctx context.Context, key string, window time.Duration) (int, error)

Increment increases the counter for key within the given window and returns the current value. If the key is new or has no expiry, it sets the expiry to the window duration.

Jump to

Keyboard shortcuts

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