memcache

package
Version: v0.0.0-...-df3943b Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2014 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

A generic memcache client library which supports connection pooling and flexible sharding.

Implementation note: this client uses memcached's binary protocol. See https://code.google.com/p/memcached/wiki/BinaryProtocolRevamped for additional details.

Index

Examples

Constants

View Source
const (
	ActiveServer    = MemcachedState(0)
	WriteOnlyServer = MemcachedState(1)
	DownServer      = MemcachedState(2)
)

Variables

This section is empty.

Functions

func NewStatusCodeError

func NewStatusCodeError(status ResponseStatus) error

Types

type BaseShardManager

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

A base shard manager implementation that can be used to implement other shard managers.

func (*BaseShardManager) GetAllShards

func (m *BaseShardManager) GetAllShards() map[int]net2.ManagedConn

See ShardManager interface for documentation.

func (*BaseShardManager) GetShard

func (m *BaseShardManager) GetShard(
	key string) (
	shardId int,
	conn net2.ManagedConn,
	err error)

See ShardManager interface for documentation.

func (*BaseShardManager) GetShardsForItems

func (m *BaseShardManager) GetShardsForItems(
	items []*Item) map[int]*ShardMapping

See ShardManager interface for documentation.

func (*BaseShardManager) GetShardsForKeys

func (m *BaseShardManager) GetShardsForKeys(
	keys []string) map[int]*ShardMapping

See ShardManager interface for documentation.

func (*BaseShardManager) GetShardsForSentinels

func (m *BaseShardManager) GetShardsForSentinels(
	items []*Item) map[int]*ShardMapping

See ShardManager interface for documentation.

func (*BaseShardManager) Init

func (m *BaseShardManager) Init(
	shardFunc func(key string, numShard int) (shard int),
	logError func(err error),
	logInfo func(v ...interface{}),
	options net2.ConnectionOptions)

Initializes the BaseShardManager.

func (*BaseShardManager) UpdateShardStates

func (m *BaseShardManager) UpdateShardStates(shardStates []ShardState)

This updates the shard manager to use new shard states.

type Client

type Client interface {
	// This retrieves a single entry from memcache.
	Get(key string) GetResponse

	// Batch version of the Get method.
	GetMulti(keys []string) map[string]GetResponse

	// This sets a single entry into memcache.  If the item's data version id
	// (aka CAS) is nonzero, the set operation can only succeed if the item
	// exists in memcache and has a same data version id.
	Set(item *Item) MutateResponse

	// Batch version of the Set method.  Note that the response entries
	// ordering is undefined (i.e., may not match the input ordering).
	SetMulti(items []*Item) []MutateResponse

	// *** This method is specific to Dropbox zookeeper-managed memcache ***
	// This is the same as SetMutli.  The only difference is that SetMulti will
	// only write to ACTIVE memcache shards, while SetSentinels will write to
	// both ACTIVE and WRITE_ONLY memcache shards.
	SetSentinels(items []*Item) []MutateResponse

	// This adds a single entry into memcache.  Note: Add will fail if the
	// item already exist in memcache.
	Add(item *Item) MutateResponse

	// This replaces a single entry in memcache.  Note: Replace will fail if
	// the does not exist in memcache.
	Replace(item *Item) MutateResponse

	// This delets a single entry from memcache.
	Delete(key string) MutateResponse

	// Batch version of the Delete method.  Note that the response entries
	// ordering is undefined (i.e., may not match the input ordering)
	DeleteMulti(keys []string) []MutateResponse

	// This appends the value bytes to the end of an existing entry.  Note that
	// this does not allow you to extend past the item limit.
	Append(key string, value []byte) MutateResponse

	// This prepends the value bytes to the end of an existing entry.  Note that
	// this does not allow you to extend past the item limit.
	Prepend(key string, value []byte) MutateResponse

	// This increments the key's counter by delta.  If the counter does not
	// exist, one of two things may happen:
	// 1. If the expiration value is all one-bits (0xffffffff), the operation
	//    will fail with StatusNotFound.
	// 2. For all other expiration values, the operation will succeed by
	//    seeding the value for this key with the provided initValue to expire
	//    with the provided expiration time. The flags will be set to zero.
	//
	// NOTE:
	// 1. If you want to set the value of the counter with add/set/replace,
	//    the objects data must be the ascii representation of the value and
	//    not the byte values of a 64 bit integer.
	// 2. Incrementing the counter may cause the counter to wrap.
	Increment(
		key string,
		delta uint64,
		initValue uint64,
		expiration uint32) CountResponse

	// This decrements the key's counter by delta.  If the counter does not
	// exist, one of two things may happen:
	// 1. If the expiration value is all one-bits (0xffffffff), the operation
	//    will fail with StatusNotFound.
	// 2. For all other expiration values, the operation will succeed by
	//    seeding the value for this key with the provided initValue to expire
	//    with the provided expiration time. The flags will be set to zero.
	//
	// NOTE:
	// 1. If you want to set the value of the counter with add/set/replace,
	//    the objects data must be the ascii representation of the value and
	//    not the byte values of a 64 bit integer.
	// 2. Decrementing a counter will never result in a "negative value" (or
	//    cause the counter to "wrap"). instead the counter is set to 0.
	Decrement(
		key string,
		delta uint64,
		initValue uint64,
		expiration uint32) CountResponse

	// This invalidates all existing cache items after expiration number of
	// seconds.
	Flush(expiration uint32) Response

	// This requests the server statistics. When the key is an empty string,
	// the server will respond with a "default" set of statistics information.
	Stat(statsKey string) StatResponse

	// This returns the server's version string.
	Version() VersionResponse

	// This set the verbosity level of the server.
	Verbosity(verbosity uint32) Response
}

func NewMockClient

func NewMockClient() Client

func NewShardedClient

func NewShardedClient(manager ShardManager) Client

This creates a new ShardedClient.

type ClientShard

type ClientShard interface {
	Client

	// This returns the memcache server's shard id.
	ShardId() int

	// This returns true if the client is in a valid state.  If the client is
	// in invalid state, the user should abandon the current client / channel,
	// and create a new client / channel as replacment.
	IsValidState() bool
}

A memcache client which communicates with a specific memcache shard.

func NewRawClient

func NewRawClient(shard int, channel io.ReadWriter) ClientShard

This creates a new memcache RawClient.

type CountResponse

type CountResponse interface {
	Response

	// This returns the input key (useful for SetMulti where operations may be
	// applied out of order).
	Key() string

	// This returns the resulting count value.  On error status, this returns
	// zero.
	Count() uint64
}

Response returned by Increment/Decrement requests.

func NewCountErrorResponse

func NewCountErrorResponse(key string, err error) CountResponse

This creates a CountResponse from an error.

func NewCountResponse

func NewCountResponse(
	key string,
	status ResponseStatus,
	count uint64) CountResponse

This creates a normal CountResponse.

type GetResponse

type GetResponse interface {
	Response

	// This returns the key for the requested value.
	Key() string

	// This returns the retreived entry.  The value may be nil.
	Value() []byte

	// This returns the entry's flags value.  The value is only valid when
	// the entry is found.
	Flags() uint32

	// This returns the data version id (aka CAS) for the item.  The value is
	// only valid when the entry is found.
	DataVersionId() uint64
}

Response returned by Get/GetKey/GetAndTouch requests.

func NewGetErrorResponse

func NewGetErrorResponse(key string, err error) GetResponse

This creates a GetResponse from an error.

func NewGetResponse

func NewGetResponse(
	key string,
	status ResponseStatus,
	flags uint32,
	value []byte,
	version uint64) GetResponse

This creates a normal GetResponse.

type Item

type Item struct {
	// The item's key (the key can be up to 250 bytes maximum).
	Key string

	// The item's value.
	Value []byte

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

	// aka CAS (check and set) in memcache documentation.
	DataVersionId uint64

	// 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 uint32
}

An item to be gotten from or stored in a memcache server.

type MemcachedState

type MemcachedState int

type MockClient

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

func (*MockClient) Add

func (c *MockClient) Add(item *Item) MutateResponse

This adds a single entry into memcache. Note: Add will fail if the item already exist in memcache.

func (*MockClient) Append

func (c *MockClient) Append(key string, value []byte) MutateResponse

This appends the value bytes to the end of an existing entry. Note that this does not allow you to extend past the item limit.

func (*MockClient) Decrement

func (c *MockClient) Decrement(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

This decrements the key's counter by delta. If the counter does not exist, one of two things may happen: 1. If the expiration value is all one-bits (0xffffffff), the operation will fail with StatusNotFound. 2. For all other expiration values, the operation will succeed by seeding the value for this key with the provided initValue to expire with the provided expiration time. The flags will be set to zero.

NOTE: 1. If you want to set the value of the counter with add/set/replace, the objects data must be the ascii representation of the value and not the byte values of a 64 bit integer. 2. Decrementing a counter will never result in a "negative value" (or cause the counter to "wrap"). instead the counter is set to 0.

func (*MockClient) Delete

func (c *MockClient) Delete(key string) MutateResponse

This delets a single entry from memcache.

func (*MockClient) DeleteMulti

func (c *MockClient) DeleteMulti(keys []string) []MutateResponse

Batch version of the Delete method. Note that the response entries ordering is undefined (i.e., may not match the input ordering)

func (*MockClient) Flush

func (c *MockClient) Flush(expiration uint32) Response

This invalidates all existing cache items after expiration number of seconds.

func (*MockClient) Get

func (c *MockClient) Get(key string) GetResponse

This retrieves a single entry from memcache.

func (*MockClient) GetMulti

func (c *MockClient) GetMulti(keys []string) map[string]GetResponse

Batch version of the Get method.

func (*MockClient) Increment

func (c *MockClient) Increment(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

This increments the key's counter by delta. If the counter does not exist, one of two things may happen: 1. If the expiration value is all one-bits (0xffffffff), the operation will fail with StatusNotFound. 2. For all other expiration values, the operation will succeed by seeding the value for this key with the provided initValue to expire with the provided expiration time. The flags will be set to zero.

NOTE: 1. If you want to set the value of the counter with add/set/replace, the objects data must be the ascii representation of the value and not the byte values of a 64 bit integer. 2. Incrementing the counter may cause the counter to wrap.

func (*MockClient) Prepend

func (c *MockClient) Prepend(key string, value []byte) MutateResponse

This prepends the value bytes to the end of an existing entry. Note that this does not allow you to extend past the item limit.

func (*MockClient) Replace

func (c *MockClient) Replace(item *Item) MutateResponse

This replaces a single entry in memcache. Note: Replace will fail if the does not exist in memcache.

func (*MockClient) Set

func (c *MockClient) Set(item *Item) MutateResponse

This sets a single entry into memcache. If the item's data version id (aka CAS) is nonzero, the set operation can only succeed if the item exists in memcache and has a same data version id.

func (*MockClient) SetMulti

func (c *MockClient) SetMulti(items []*Item) []MutateResponse

Batch version of the Set method. Note that the response entries ordering is undefined (i.e., may not match the input ordering).

func (*MockClient) SetSentinels

func (c *MockClient) SetSentinels(items []*Item) []MutateResponse

func (*MockClient) Stat

func (c *MockClient) Stat(statsKey string) StatResponse

This requests the server statistics. When the key is an empty string, the server will respond with a "default" set of statistics information.

func (*MockClient) Verbosity

func (c *MockClient) Verbosity(verbosity uint32) Response

This set the verbosity level of the server.

func (*MockClient) Version

func (c *MockClient) Version() VersionResponse

This returns the server's version string.

type MutateResponse

type MutateResponse interface {
	Response

	// This returns the input key (useful for SetMulti where operations may be
	// applied out of order).
	Key() string

	// This returns the data version id (aka CAS) for the item.  For delete
	// requests, this always returns zero.
	DataVersionId() uint64
}

Response returned by Set/Add/Replace/Delete/Append/Prepend requests.

func NewMutateErrorResponse

func NewMutateErrorResponse(key string, err error) MutateResponse

This creates a MutateResponse from an error.

func NewMutateResponse

func NewMutateResponse(
	key string,
	status ResponseStatus,
	version uint64) MutateResponse

This creates a normal MutateResponse.

type RawClient

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

An unsharded memcache client implementation which operates on a pre-existing io channel (The user must explicitly setup and close down the channel). Note that the client assumes nothing else is sending or receiving on the network channel. In general, all client operations are serialized (Use multiple channels / clients if parallelism is needed).

Example
package main

import (
	"fmt"
	"net"

	"github.com/dropbox/godropbox/memcache"
)

func main() {
	conn, _ := net.Dial("tcp", "localhost:11211")

	client := memcache.NewRawClient(0, conn)

	get := func(key string) {
		resp := client.Get(key)
		fmt.Println("Get", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
		fmt.Println("  Value:", resp.Value())
	}

	set := func(item *memcache.Item) {
		resp := client.Set(item)
		fmt.Println("Set", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
	}

	del := func(key string) {
		resp := client.Delete(key)
		fmt.Println("Delete", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
	}

	item := memcache.Item{
		Key:   "bar",
		Value: []byte("Hello World"),
		Flags: uint32(123),
	}

	get("foo")
	get("bar")
	set(&item)
	get("bar")
	del("bar")
	get("bar")
}
Output:

func (*RawClient) Add

func (c *RawClient) Add(item *Item) MutateResponse

See Client interface for documentation.

func (*RawClient) Append

func (c *RawClient) Append(key string, value []byte) MutateResponse

See Client interface for documentation.

func (*RawClient) Decrement

func (c *RawClient) Decrement(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

See Client interface for documentation.

func (*RawClient) Delete

func (c *RawClient) Delete(key string) MutateResponse

See Client interface for documentation.

func (*RawClient) DeleteMulti

func (c *RawClient) DeleteMulti(keys []string) []MutateResponse

See Client interface for documentation.

func (*RawClient) Flush

func (c *RawClient) Flush(expiration uint32) Response

See Client interface for documentation.

func (*RawClient) Get

func (c *RawClient) Get(key string) GetResponse

See Client interface for documentation.

func (*RawClient) GetMulti

func (c *RawClient) GetMulti(keys []string) map[string]GetResponse

See Client interface for documentation.

func (*RawClient) Increment

func (c *RawClient) Increment(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

See Client interface for documentation.

func (*RawClient) IsValidState

func (c *RawClient) IsValidState() bool

See ClientShard interface for documentation.

func (*RawClient) Prepend

func (c *RawClient) Prepend(key string, value []byte) MutateResponse

See Client interface for documentation.

func (*RawClient) Replace

func (c *RawClient) Replace(item *Item) MutateResponse

See Client interface for documentation.

func (*RawClient) Set

func (c *RawClient) Set(item *Item) MutateResponse

See Client interface for documentation.

func (*RawClient) SetMulti

func (c *RawClient) SetMulti(items []*Item) []MutateResponse

See Client interface for documentation.

func (*RawClient) SetSentinels

func (c *RawClient) SetSentinels(items []*Item) []MutateResponse

See Client interface for documentation.

func (*RawClient) ShardId

func (c *RawClient) ShardId() int

See ClientShard interface for documentation.

func (*RawClient) Stat

func (c *RawClient) Stat(statsKey string) StatResponse

See Client interface for documentation.

func (*RawClient) Verbosity

func (c *RawClient) Verbosity(verbosity uint32) Response

See Client interface for documentation.

func (*RawClient) Version

func (c *RawClient) Version() VersionResponse

See Client interface for documentation.

type Response

type Response interface {
	// This returns the status returned by the memcache server.  When Error()
	// is non-nil, this value may not be valid.
	//
	// NOTE:
	// 1. For stat request, this returns the first non-StatusNoError encountered
	//    (or StatusNoError if there were no errors).
	// 2. If the client is sharded, flush/stats/version/verbosity requests
	//    will return the first non-StatusNoError encountered (or StatusNoError
	//    if there were no errors).
	Status() ResponseStatus

	// This returns nil when no error is encountered by the client, and the
	// response status returned by the memcache server is StatusNoError.
	// Otherwise, this returns an error.
	//
	// NOTE:
	// 1. For get requests, this also returns nil when the response status
	//    StatusKeyNotFound.
	// 2. For stat request, this returns the first error encountered (or nil
	//    if there were no errors).
	// 3. If the client is sharded, flush/stats/version/verbosity requests
	//    will return the first error encountered (or nil if there were no
	//    errors).
	Error() error
}

A generic response to a memcache request.

func NewErrorResponse

func NewErrorResponse(err error) Response

This creates a Response from an error.

func NewResponse

func NewResponse(status ResponseStatus) Response

This creates a Response from status.

type ResponseStatus

type ResponseStatus uint16
const (
	StatusNoError ResponseStatus = iota
	StatusKeyNotFound
	StatusKeyExists
	StatusValueTooLarge
	StatusInvalidArguments
	StatusItemNotStored
	StatusIncrDecrOnNonNumericValue
	StatusVbucketBelongsToAnotherServer // Not used
	StatusAuthenticationError           // Not used
	StatusAuthenticationContinue        // Not used
)
const (
	StatusUnknownCommand ResponseStatus = 0x81 + iota
	StatusOutOfMemory
	StatusNotSupported
	StatusInternalError
	StatusBusy
	StatusTempFailure
)

type ShardManager

type ShardManager interface {
	// This returns the shard id and a connection to shard for a single key.
	// If the key does not belong to any shard, this returns (-1, nil). Note
	// that the connection may be nil for valid shard id (for instance, if
	// the shard server is temporarily unavailable).
	GetShard(key string) (shardId int, conn net2.ManagedConn, err error)

	// This returns a (shard id -> (connection, list of keys)) mapping for
	// the requested keys.  Keys that do not belong to any shard are mapped
	// to shard id -1.
	GetShardsForKeys(keys []string) map[int]*ShardMapping

	// This returns a (shard id -> (connection, list of items)) mapping for
	// the requested items.  Items that do not belong to any shard are mapped
	// to shard id -1.
	GetShardsForItems(items []*Item) map[int]*ShardMapping

	// *** This method is specific to Dropbox zookeeper-managed memcache ***
	// This returns a (shard id -> (connection, list of items)) mapping for
	// the requested sentinel items.  Sential items that do not belong to any
	// shard are mapped to shard id -1.
	GetShardsForSentinels(items []*Item) map[int]*ShardMapping

	// This return a (shard id -> connection) mapping for all shards.
	GetAllShards() map[int]net2.ManagedConn
}

The ShardManager decides which memcache shard a key/item belongs to, and provide connections to the shards.

func NewStaticShardManager

func NewStaticShardManager(
	serverAddrs []string,
	shardFunc func(key string, numShard int) (shard int),
	options net2.ConnectionOptions) ShardManager

This creates a StaticShardManager, which returns connections from a static list of memcache shards.

type ShardMapping

type ShardMapping struct {
	Connection net2.ManagedConn
	ConnErr    error
	Keys       []string // Populated for GetShardsForKeys
	Items      []*Item  // Populated for GetShardsForItems
}

Used for returning shard mapping results from ShardManager's GetShardsForKeys/GetShardsForItems calls.

type ShardState

type ShardState struct {
	Address string
	State   MemcachedState
}

type ShardedClient

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

A sharded memcache client implementation where sharding management is handled by the provided ShardManager.

Example
package main

import (
	"fmt"
	"hash/crc32"

	"github.com/dropbox/godropbox/memcache"
	"github.com/dropbox/godropbox/net2"
)

func main() {
	options := net2.ConnectionOptions{
		MaxActiveConnections: 4,
	}
	manager := memcache.NewStaticShardManager(
		[]string{"localhost:11211", "localhost:11212"},
		func(key string, numShard int) int {
			return int(crc32.ChecksumIEEE([]byte(key))) % 2
		},
		options)

	client := memcache.NewShardedClient(manager)

	get := func(key string) {
		resp := client.Get(key)
		fmt.Println("Get", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
		fmt.Println("  Value:", string(resp.Value()))
	}

	set := func(item *memcache.Item) {
		resp := client.Set(item)
		fmt.Println("Set", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
	}

	del := func(key string) {
		resp := client.Delete(key)
		fmt.Println("Delete", resp.Key())
		fmt.Println(
			"  Status:",
			resp.Status(),
			"-",
			memcache.NewStatusCodeError(resp.Status()))
		fmt.Println("  Error:", resp.Error())
	}

	item := memcache.Item{
		Key:   "bar",
		Value: []byte("Hello World"),
		Flags: uint32(123),
	}

	get("foo")
	get("bar")
	set(&item)
	get("bar")
	del("bar")
	get("bar")
}
Output:

func (*ShardedClient) Add

func (c *ShardedClient) Add(item *Item) MutateResponse

See Client interface for documentation.

func (*ShardedClient) Append

func (c *ShardedClient) Append(key string, value []byte) MutateResponse

See Client interface for documentation.

func (*ShardedClient) Decrement

func (c *ShardedClient) Decrement(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

See Client interface for documentation.

func (*ShardedClient) Delete

func (c *ShardedClient) Delete(key string) MutateResponse

See Client interface for documentation.

func (*ShardedClient) DeleteMulti

func (c *ShardedClient) DeleteMulti(keys []string) []MutateResponse

See Client interface for documentation.

func (*ShardedClient) Flush

func (c *ShardedClient) Flush(expiration uint32) Response

See Client interface for documentation.

func (*ShardedClient) Get

func (c *ShardedClient) Get(key string) GetResponse

See Client interface for documentation.

func (*ShardedClient) GetMulti

func (c *ShardedClient) GetMulti(keys []string) map[string]GetResponse

See Client interface for documentation.

func (*ShardedClient) Increment

func (c *ShardedClient) Increment(
	key string,
	delta uint64,
	initValue uint64,
	expiration uint32) CountResponse

See Client interface for documentation.

func (*ShardedClient) Prepend

func (c *ShardedClient) Prepend(key string, value []byte) MutateResponse

See Client interface for documentation.

func (*ShardedClient) Replace

func (c *ShardedClient) Replace(item *Item) MutateResponse

See Client interface for documentation.

func (*ShardedClient) Set

func (c *ShardedClient) Set(item *Item) MutateResponse

See Client interface for documentation.

func (*ShardedClient) SetMulti

func (c *ShardedClient) SetMulti(items []*Item) []MutateResponse

See Client interface for documentation.

func (*ShardedClient) SetSentinels

func (c *ShardedClient) SetSentinels(items []*Item) []MutateResponse

See Client interface for documentation.

func (*ShardedClient) Stat

func (c *ShardedClient) Stat(statsKey string) StatResponse

See Client interface for documentation.

func (*ShardedClient) Verbosity

func (c *ShardedClient) Verbosity(verbosity uint32) Response

See Client interface for documentation.

func (*ShardedClient) Version

func (c *ShardedClient) Version() VersionResponse

See Client interface for documentation.

type StatResponse

type StatResponse interface {
	Response

	// This returns the retrieved stat entries.  On error status, this returns
	// nil.  The mapping is stored as:
	//      shard id -> stats key -> stats value
	// (If the client is unsharded, the shard id is always zero).
	Entries() map[int](map[string]string)
}

Response returned by Stat request.

func NewStatErrorResponse

func NewStatErrorResponse(
	err error,
	entries map[int](map[string]string)) StatResponse

This creates a StatResponse from an error.

func NewStatResponse

func NewStatResponse(
	status ResponseStatus,
	entries map[int](map[string]string)) StatResponse

This creates a normal StatResponse.

type StaticShardManager

type StaticShardManager struct {
	BaseShardManager
}

A shard manager that returns connections from a static list of memcache shards. NOTE: This is only for illustration purposes. DO NOT USE IN PRODUCTION.

type VersionResponse

type VersionResponse interface {
	Response

	// This returns the memcache version entries.  On error status, this
	// returns an empty string.  The mapping is stored as:
	//      shard id -> version string
	// (If the client is unsharded, the shard id is always zero).
	Versions() map[int]string
}

Response returned by Version request.

func NewVersionErrorResponse

func NewVersionErrorResponse(
	err error,
	versions map[int]string) VersionResponse

This creates a VersionResponse from an error.

func NewVersionResponse

func NewVersionResponse(
	status ResponseStatus,
	versions map[int]string) VersionResponse

This creates a normal VersionResponse.

Jump to

Keyboard shortcuts

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