caches

package
v0.0.0-...-003ee67 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryCache

type InMemoryCache struct {
	DefaultExpiry time.Duration
	Cache         *goCache.Cache
}

InMemoryCache - Simple cache structure that is used for in-memory rate limiting.

func NewInMemoryCache

func NewInMemoryCache(defaultExpiry time.Duration) InMemoryCache

NewInMemoryCache - Creates a new in-memory cache to be consumed by rate-limiter.

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(key string) string

Get - Retrieves object for key pair from go-cache.

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(key string, object string, duration time.Duration)

Set - Writes object for key to go-cache.

type RateCache

type RateCache interface {
	Set(key string, object string, duration time.Duration)
	Get(key string) string
}

RateCache - abstracts the cache backend. Any cache struct that implements this interface can be used for rate limiting.

type RedisCache

type RedisCache struct {
	DefaultExpiry time.Duration
	Client        *redis.Client
}

RedisCache - Simple cache structure that is uses redis rate limiting.

func NewRedisCache

func NewRedisCache(defaultExpiry time.Duration, client *redis.Client) RedisCache

NewRedisCache - Creates a new redis cache to be consumed by rate-limiter.

func (*RedisCache) Get

func (c *RedisCache) Get(key string) string

Get - Retrieves object for key pair from redis.

func (*RedisCache) Set

func (c *RedisCache) Set(key string, object string, duration time.Duration)

Set - Writes object for key to redis.

Jump to

Keyboard shortcuts

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