cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICache

type ICache interface {
	AddCounter(ip string, duration time.Duration)
	IsAllowed(ip string, requestNumber int) bool
}

func GetCacheHandler

func GetCacheHandler(name RateLimitCacheType) ICache

GetCacheHandler cache builder ( factory method )

type RateLimitCacheType added in v0.1.1

type RateLimitCacheType int8
const (
	RedisBackend RateLimitCacheType = iota
)

type Redis

type Redis struct {
	Host string
	Db   int8
	Port int16
}

Redis struct that implement ICache interface

func (Redis) AddCounter

func (r Redis) AddCounter(ip string, duration time.Duration)

AddCounter create or increment user rate

func (Redis) IsAllowed

func (r Redis) IsAllowed(ip string, requestNumber int) bool

IsAllowed check user rate

Jump to

Keyboard shortcuts

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