memcache

package module
v0.0.0-...-22d46f4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

memcache

An expelimental implementation of Memcached client with Go

Documentation

Overview

Package memcache provides a memcache client

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCacheMiss means that a Get failed because the item wasn't present.
	ErrCacheMiss = errors.New("memcache: cache miss")

	// ErrCASConflict means that a CompareAndSwap call failed due to the
	// cached value being modified between the Get and the CompareAndSwap.
	// If the cached value was simply evicted rather than replaced,
	// ErrNotStored will be returned instead.
	ErrCASConflict = errors.New("memcache: compare-and-swap conflict")

	// ErrNotStored means that a conditional write operation (i.e. Add or
	// CompareAndSwap) failed because the condition was not satisfied.
	ErrNotStored = errors.New("memcache: item not stored")

	// ErrServer means that a server error occurred.
	ErrServerError = errors.New("memcache: server error")

	// ErrNoStats means that no statistics were available.
	ErrNoStats = errors.New("memcache: no statistics available")

	// ErrMalformedKey is returned when an invalid key is used.
	// Keys must be at maximum 250 bytes long and not
	// contain whitespace or control characters.
	ErrMalformedKey = errors.New("malformed: key is too long or contains invalid characters")

	// ErrNoServers is returned when no servers are configured or available.
	ErrNoServers = errors.New("memcache: no servers configured or available")

	// ErrMagicByte is returned when magic byte of the packet is invalid.
	ErrMagicByte = errors.New("memcache: invalid magic byte")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(servers ...string) *Client

func (*Client) Add

func (c *Client) Add(item *Item) error

func (*Client) CompareAndSwap

func (c *Client) CompareAndSwap(item *Item) error

func (*Client) Decrement

func (c *Client) Decrement(key string, delta uint64, initialValue uint64, expiration int) (uint64, error)

func (*Client) Delete

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

func (*Client) Flush

func (c *Client) Flush(expiration int) error

func (*Client) Get

func (c *Client) Get(key string) (*Item, error)

func (*Client) GetMulti

func (c *Client) GetMulti(keys []string) (map[string]*Item, error)

func (*Client) Increment

func (c *Client) Increment(key string, delta uint64, initialValue uint64, expiration int) (uint64, error)

func (*Client) Replace

func (c *Client) Replace(item *Item) error

func (*Client) Set

func (c *Client) Set(item *Item) error

type Item

type Item struct {
	// Key is the Item's key (250 bytes maximum).
	Key string

	// Value is the Item's value.
	Value []byte

	// Flags are server-opaque flags whose semantics are entirely
	// up to the app.
	Flags uint32

	// Expiration is the cache expiration time, in seconds: either a relative
	// time from now (up to 1 month), or an absolute Unix epoch time.
	// Zero means the Item has no expiration time.
	Expiration int32
	// contains filtered or unexported fields
}

Item is an item to be got or stored in a memcached server.

Jump to

Keyboard shortcuts

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