cache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: BSD-2-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout  = errors.New("cache: timeout")
	ErrNotFound = errors.New("cache: not found")
)

Functions

This section is empty.

Types

type BytesCache

type BytesCache interface {
	Get(k string) ([]byte, error)
	Set(k string, v []byte, expire int32)
}

func NewExpireCache

func NewExpireCache(maxsize uint64) BytesCache

func NewMemcached

func NewMemcached(prefix string, timeoutMs uint64, servers ...string) BytesCache

func NewReplicatedMemcached added in v0.2.0

func NewReplicatedMemcached(prefix string, timeout uint64, servers ...string) BytesCache

NewReplicatedMemcached creates a set of identical memcached instances.

type Cache added in v0.2.0

type Cache interface {
	Get(string) (*memcache.Item, error)
	Set(*memcache.Item) error
}

Cache is a cache interface. Mainly for testing abilities.

type ExpireCache

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

func (ExpireCache) Get

func (ec ExpireCache) Get(k string) ([]byte, error)

func (ExpireCache) Items

func (ec ExpireCache) Items() int

func (ExpireCache) Set

func (ec ExpireCache) Set(k string, v []byte, expire int32)

func (ExpireCache) Size

func (ec ExpireCache) Size() uint64

type MemcachedCache

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

func (*MemcachedCache) Get

func (m *MemcachedCache) Get(k string) ([]byte, error)

func (*MemcachedCache) Set

func (m *MemcachedCache) Set(k string, v []byte, expire int32)

func (*MemcachedCache) Timeouts

func (m *MemcachedCache) Timeouts() uint64

type NullCache

type NullCache struct{}

func (NullCache) Get

func (NullCache) Get(string) ([]byte, error)

func (NullCache) Set

func (NullCache) Set(string, []byte, int32)

type ReplicatedMemcached added in v0.2.0

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

ReplicatedMemcached represents the caching setup when all the memcached instances are identical. Each read and write refers to all of them.

func (*ReplicatedMemcached) Get added in v0.2.0

func (m *ReplicatedMemcached) Get(k string) ([]byte, error)

Get gets value for the key from the replicated memcached. It sends the request to all replicas and picks the first valid answer (event if it's a not-found) or times out.

func (*ReplicatedMemcached) Set added in v0.2.0

func (rm *ReplicatedMemcached) Set(k string, val []byte, expire int32)

Set sets the key-value pair for all cache instances.

Jump to

Keyboard shortcuts

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