Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Get(key string) (*Response, bool)
	Set(key string, response *Response, expiration time.Time)
	Remove(key string)
}

func NewAdapter

func NewAdapter(cfg common.Config) (Adapter, error)

type Client

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

func NewClient

func NewClient(opts ...ClientOption) (*Client, error)

func (*Client) Middleware

func (c *Client) Middleware(next http.Handler) http.Handler

func (*Client) WrapHandlerFunc

func (c *Client) WrapHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc

type ClientOption

type ClientOption func(c *Client) error

func WithAdapter

func WithAdapter(a Adapter) ClientOption

func WithExpire

func WithExpire(ttl time.Duration) ClientOption

func WithLogger

func WithLogger(logger logging.Logger) ClientOption

func WithMethods

func WithMethods(methods ...string) ClientOption

func WithOptions

func WithOptions(options ...ClientOption) ClientOption

func WithStatusCode

func WithStatusCode(code int, ttl time.Duration) ClientOption

type MemCacheAdapter

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

func NewMemCacheAdapter

func NewMemCacheAdapter(size int) *MemCacheAdapter

func (*MemCacheAdapter) Get

func (a *MemCacheAdapter) Get(key string) (*Response, bool)

func (*MemCacheAdapter) Remove

func (a *MemCacheAdapter) Remove(key string)

func (*MemCacheAdapter) Set

func (a *MemCacheAdapter) Set(key string, resp *Response, expir time.Time)

type NopClient

type NopClient struct {
}

func NewNopClient

func NewNopClient() *NopClient

func (NopClient) WrapHandlerFunc

func (NopClient) WrapHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc

type RedisCacheAdapter

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

func NewRedisCacheAdapter

func NewRedisCacheAdapter(opt *RedisRingOptions) *RedisCacheAdapter

func (*RedisCacheAdapter) Get

func (a *RedisCacheAdapter) Get(key string) (*Response, bool)

func (*RedisCacheAdapter) Remove

func (a *RedisCacheAdapter) Remove(key string)

func (*RedisCacheAdapter) Set

func (a *RedisCacheAdapter) Set(key string, resp *Response, expir time.Time)

type RedisRingOptions

type RedisRingOptions redis.RingOptions

type Response

type Response struct {
	Value      []byte
	StatusCode int
	Header     http.Header
	Expiration time.Time
}

type Wrapper

type Wrapper interface {
	WrapHandlerFunc(handlerFunc http.HandlerFunc) http.HandlerFunc
}