cache

package
v0.0.0-...-5787b36 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT = time.Duration(0)
	FOREVER = time.Duration(-1)
)

Variables

View Source
var ErrCacheMiss = errors.New("cache missing")

Functions

This section is empty.

Types

type Cache

type Cache struct {
	KeyPrefix string
	Store
}

func (*Cache) Cache

func (cache *Cache) Cache(expire time.Duration, handler mel.Handler) mel.Handler

func (*Cache) Middleware

func (cache *Cache) Middleware(expire time.Duration) mel.Handler

type MemoryStore

type MemoryStore struct {
	*memory.Cache
}

func NewMemoryStore

func NewMemoryStore(defaultExpiration, cleanupInterval time.Duration) *MemoryStore

func (*MemoryStore) Clear

func (c *MemoryStore) Clear() error

func (*MemoryStore) Delete

func (c *MemoryStore) Delete(key string) error

func (*MemoryStore) Get

func (c *MemoryStore) Get(key string, ptr interface{}) error

func (*MemoryStore) Set

func (c *MemoryStore) Set(key string, value interface{}, expire time.Duration) error

type RedisStore

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

func NewRedisStore

func NewRedisStore(host, password string, defaultExpiration time.Duration) *RedisStore

func (*RedisStore) Clear

func (c *RedisStore) Clear() error

func (*RedisStore) Delete

func (c *RedisStore) Delete(key string) error

func (*RedisStore) Get

func (c *RedisStore) Get(key string, ptr interface{}) error

func (*RedisStore) Set

func (c *RedisStore) Set(key string, value interface{}, expire time.Duration) error

type Store

type Store interface {
	// Get retrieves item from cache, and return nil.
	// If the key is not found, return ErrCacheMiss.
	// Value must be a pointer.
	Get(key string, ptr interface{}) error

	// Set sets item to cache.
	// If the key exists, replace the item.
	Set(key string, value interface{}, expire time.Duration) error

	// Delete removes item from cache.
	// If the key does not exist, do nothing.
	Delete(key string) error

	// Clear all items from
	Clear() error
}

Jump to

Keyboard shortcuts

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