cachemanager

package
v0.0.0-...-8268df1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2016 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCacheFull                = errors.New("Cache full")
	ErrCacheMiss                = errors.New("Cache miss")
	ErrInvalidHandler           = errors.New("Invalid handler")
	ErrInputMustBeASliceOfBytes = errors.New("Input must be a slice of bytes")
)

Vars

Functions

func FromBytes

func FromBytes(i []byte, o interface{}) error

func ToBytes

func ToBytes(d interface{}) ([]byte, error)

Types

type Configuration

type Configuration struct {
	Prefix string `json:"prefix"`
	TTL    int64  `json:"ttl"`
}

type ConfigurationMemcache

type ConfigurationMemcache struct {
	Configuration
	Servers string `json:"servers"`
}

type ConfigurationMemory

type ConfigurationMemory struct {
	CleanupInterval int64 `json:"cleanup_interval"`
	Configuration
	MaxSize int64 `json:"max_size"`
}

type ConfigurationRedis

type ConfigurationRedis struct {
	Configuration
	Addr string `json:"addr"`
}

type Handler

type Handler interface {
	Decrement(key string, delta uint64) (uint64, error)
	Del(k string) error
	Get(k string) (interface{}, error)
	Increment(key string, delta uint64) (uint64, error)
	SetOnEvicted(f func(k string, v interface{})) Handler
	Set(k string, v interface{}, ttl time.Duration) error
	Test() error
}

func MockHandler

func MockHandler() Handler

func NewHandlerMemcache

func NewHandlerMemcache(servers string, prefix string, ttl time.Duration) Handler

NewHandlerMemcache creates a memcache handler

func NewHandlerMemcacheFromConfiguration

func NewHandlerMemcacheFromConfiguration(c ConfigurationMemcache) Handler

NewHandlerMemcacheFromConfiguration creates a memcache handler based on a configuration

func NewHandlerMemory

func NewHandlerMemory(cleanupInterval time.Duration, maxSize int64, prefix string, ttl time.Duration) Handler

NewHandlerMemory creates a memory handler

func NewHandlerMemoryFromConfiguration

func NewHandlerMemoryFromConfiguration(c ConfigurationMemory) Handler

NewHandlerMemoryFromConfiguration creates a memory handler based on a configuration

func NewHandlerRedis

func NewHandlerRedis(redisConfig *redis.Options, prefix string, ttl time.Duration) Handler

NewHandlerRedis creates a redis handler

func NewHandlerRedisFromConfiguration

func NewHandlerRedisFromConfiguration(conf *ConfigurationRedis) Handler

type Manager

type Manager interface {
	AddHandler(n string, h Handler) Manager
	Del(k string) error
	Get(k string) (interface{}, error)
	GetHandler(n string) (Handler, error)
	Test() map[string]error
}

Manager represents a cache manager capable of switching between several cache handlers

func NewManager

func NewManager() Manager

NewManager creates a new cache manager

Jump to

Keyboard shortcuts

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