redis

package
v0.0.0-...-0e41c98 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthCheck

func HealthCheck(ctx context.Context, client *redis.Client) error

HealthCheck performs a health check on the Redis connection

func NewRedisClient

func NewRedisClient(addr, password string, db int) *redis.Client

NewRedisClient creates a new Redis client with the given configuration

Types

type RateLimiter

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

RateLimiter provides Redis-based rate limiting functionality

func NewRateLimiter

func NewRateLimiter(client *redis.Client, limit int, window time.Duration) *RateLimiter

NewRateLimiter creates a new Redis-based rate limiter

func (*RateLimiter) GetCurrentCount

func (rl *RateLimiter) GetCurrentCount(ctx context.Context, userID string) (int, error)

GetCurrentCount returns the current count for a user

func (*RateLimiter) GetRemainingCount

func (rl *RateLimiter) GetRemainingCount(ctx context.Context, userID string) (int, error)

GetRemainingCount returns remaining notifications allowed for a user

func (*RateLimiter) GetTTL

func (rl *RateLimiter) GetTTL(ctx context.Context, userID string) (time.Duration, error)

GetTTL returns the remaining time until the rate limit resets

func (*RateLimiter) IsAllowed

func (rl *RateLimiter) IsAllowed(ctx context.Context, userID string) (bool, error)

IsAllowed checks if a user is allowed to send a notification

func (*RateLimiter) Reset

func (rl *RateLimiter) Reset(ctx context.Context, userID string) error

Reset resets the rate limit for a user (useful for testing)

Jump to

Keyboard shortcuts

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