cache

package
v0.0.0-...-ded3010 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

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

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

func (*LRUCache) Cap

func (c *LRUCache) Cap() int

func (*LRUCache) Delete

func (c *LRUCache) Delete(key interface{}) bool

func (*LRUCache) Get

func (c *LRUCache) Get(key interface{}) (interface{}, bool)

func (*LRUCache) Len

func (c *LRUCache) Len() int

func (*LRUCache) LoadFactor

func (c *LRUCache) LoadFactor() float64

func (*LRUCache) Put

func (c *LRUCache) Put(key, val interface{}, expire time.Duration)

type MemoryRateLimit

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

func NewMemoryRateLimit

func NewMemoryRateLimit() *MemoryRateLimit

func (*MemoryRateLimit) RateLimit

func (mrl *MemoryRateLimit) RateLimit(ctx context.Context, key string, rate int, t time.Duration) error

type Rate

type Rate struct {
	Rate     int
	Duration time.Duration
}

type RateLimitError

type RateLimitError struct {
	Rate Rate
}

RateLimitError info

func (RateLimitError) Error

func (rle RateLimitError) Error() string

type RateLimiter

type RateLimiter interface {
	RateLimit(ctx context.Context, key string, rate int, t time.Duration) error
}

To enable rate limiting such as registration per IP, 2fa guessing etc, by default it will use internal memory for rate limiting you can use distributed caching here

Jump to

Keyboard shortcuts

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