memcache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LostConnection = []string{
	"reset by peer",
	"connection refused",
}

Functions

func CheckError

func CheckError(err error)

func ContainInArray

func ContainInArray(str string, arr []string) bool

Types

type Manager

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

func NewManager

func NewManager(conf *gjson.Result) (*Manager, error)

func (*Manager) Mc

func (m *Manager) Mc(name string) (*Memcache, error)

type Memcache

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

func NewMemcache

func NewMemcache(name string, mc *memcache.Client) *Memcache

func (*Memcache) Add

func (m *Memcache) Add(key string, value []byte, expiration int32) bool

Add writes the given item, if no value already exists for its key. ErrNotStored is returned if that condition is not met.

func (*Memcache) Conn

func (m *Memcache) Conn() *memcache.Client

func (*Memcache) Decrement

func (m *Memcache) Decrement(key string, delta uint64) uint64

Decrement atomically decrements key by delta. The return value is the new value after being decremented or an error. If the value didn't exist in memcached the error is ErrCacheMiss. The value in memcached must be an decimal number, or an error will be returned. On underflow, the new value is capped at zero and does not wrap around.

func (*Memcache) Delete

func (m *Memcache) Delete(key string) error

Delete deletes the item with the provided key. The error ErrCacheMiss is returned if the item didn't already exist in the cache.

func (*Memcache) Get

func (m *Memcache) Get(key string) []byte

Get gets the item for the given key. The key must be at most 250 bytes in length.

func (*Memcache) GetMulti

func (m *Memcache) GetMulti(keys []string) map[string][]byte

GetMulti is a batch version of Get. The returned map from keys to items may have fewer elements than the input slice, due to memcache cache misses. Each key must be at most 250 bytes in length. If no error is returned, the returned map will also be non-nil.

func (*Memcache) Increment

func (m *Memcache) Increment(key string, delta uint64) uint64

Increment atomically increments key by delta. The return value is the new value after being incremented or an error. If the value didn't exist in memcached the error is ErrCacheMiss. The value in memcached must be an decimal number, or an error will be returned. On 64-bit overflow, the new value wraps around.

func (*Memcache) Replace

func (m *Memcache) Replace(key string, value []byte, expiration int32) error

Replace writes the given item, but only if the server *does* already hold data for this key

func (*Memcache) Set

func (m *Memcache) Set(key string, value []byte, expiration int32) bool

Set writes the given item, unconditionally.

func (*Memcache) Touch

func (m *Memcache) Touch(key string, seconds int32) error

Touch updates the expiry for the given key. The seconds parameter is either a Unix timestamp or, if seconds is less than 1 month, the number of seconds into the future at which time the item will expire. Zero means the item has no expiration time. ErrCacheMiss is returned if the key is not in the cache. The key must be at most 250 bytes in length.

Jump to

Keyboard shortcuts

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