Documentation
¶
Index ¶
- Constants
- Variables
- func KetamaHash(key string, index uint32) []uint32
- func MakeHash(key string) uint32
- func WriteUint16(buffer *ByteBuffer, value uint16)
- func WriteUint32(buffer *ByteBuffer, value uint32)
- func WriteUint64(buffer *ByteBuffer, value uint64)
- type Client
- type Cluster
- func (cl *Cluster) AddServer2Cluster(addr string, maxConnPerServer uint32) error
- func (cl *Cluster) ChooseServerCommanderByKey(key string) (*Server, *Commander, error)
- func (cl *Cluster) ChooseServerCommanderByServerAddr(addr string) (*Server, *Commander, error)
- func (cl *Cluster) ReleaseServerCommander(s *Server, cmder *Commander)
- type CodecDecoder
- type CodecEncoder
- type Commander
- type Decoder
- type Encoder
- type KeyArgs
- type MemcachedClient
- func (m *MemcachedClient) Add(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) AddRawData(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) AddServer(addr string, maxConnPerServer uint32) error
- func (m *MemcachedClient) Append(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) Decrement(args *KeyArgs) (uint64, uint64, error)
- func (m *MemcachedClient) Exit()
- func (m *MemcachedClient) Flush(args *KeyArgs) error
- func (m *MemcachedClient) Get(key string, value interface{}) (uint64, error)
- func (m *MemcachedClient) Increment(args *KeyArgs) (uint64, uint64, error)
- func (m *MemcachedClient) Prepend(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) Replace(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) ReplaceRawData(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) Set(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) SetRawData(args *KeyArgs) (uint64, error)
- func (m *MemcachedClient) SetServerErrorCallback(errCall ServerErrorCallback)
- func (m *MemcachedClient) TouchAtomicValue(key string) (uint64, error)
- type RequestHeader
- type Server
- type ServerErrorCallback
- type SortList
- type StatusError
Constants ¶
View Source
const ( MAGIC_REQUEST uint8 = 0x80 MAGIC_RESPONSE uint8 = 0x81 )
View Source
const ( STATUS_OK uint16 = 0x0000 STATUS_KEY_NOT_FOUND uint16 = 0x0001 STATUS_KEY_EXISTS uint16 = 0x0002 STATUS_VALUE_TOO_LARGE uint16 = 0x0003 STATUS_INVALID_ARGS uint16 = 0x0004 STATUS_NOT_STORED uint16 = 0x0005 STATUS_NON_NUMERIC_VALUE uint16 = 0x0006 STATUS_VBUCKET_NOT_FOUND uint16 = 0x0007 STATUS_AUTH_ERROR uint16 = 0x0008 STATUS_AUTH_CONTINUE uint16 = 0x0009 STATUS_UNKNOWN_COMMAND uint16 = 0x0081 STATUS_OUT_OF_MEMORY uint16 = 0x0082 STATUS_NOT_SUPPORTED uint16 = 0x0083 STATUS_INTERNAL_ERROR uint16 = 0x0084 STATUS_BUSY uint16 = 0x0085 STATUS_TEMPORARY_FAILURE uint16 = 0x0086 )
View Source
const ( OPCODE_GET uint8 = 0x00 OPCODE_SET uint8 = 0x01 OPCODE_ADD uint8 = 0x02 OPCODE_REPLACE uint8 = 0x03 OPCODE_DEL uint8 = 0x04 OPCODE_INCR uint8 = 0x05 OPCODE_DECR uint8 = 0x06 OPCODE_QUIT uint8 = 0x07 OPCODE_FLUSH uint8 = 0x08 OPCODE_NOOP uint8 = 0x0a OPCODE_VERSION uint8 = 0x0b OPCODE_GETK uint8 = 0x0c OPCODE_APPEND uint8 = 0x0e OPCODE_PREPEND uint8 = 0x0f OPCODE_STAT uint8 = 0x10 )
View Source
const ( REQ_HEADER_LEN int = 24 RSP_HEADER_LEN int = 24 )
View Source
const (
RAW_DATA uint8 = 0x00
)
View Source
const (
USE_MSGP_FLAG uint32 = 0x01
)
Variables ¶
View Source
var ( NodeRepetitions = 160 RingPosition = 4 CommanderID int64 = 10000 )
View Source
var ( ConnectTimeout = time.Duration(5) * time.Second ReadTimeout = time.Duration(5) * time.Second WriterTimeout = time.Duration(5) * time.Second )
View Source
var ( ErrInvalidArguments = errors.New("Invalid arguments") ErrNotConnected = errors.New("Not connected server") ErrConnError = errors.New("Connection error") ErrFillRequestHeaderFailed = errors.New("Fill request header failed") ErrNotFoundServerNode = errors.New("Not found server node") ErrNoUsableConnection = errors.New("No usable connection") ErrBadConnection = errors.New("Bad connection") ErrServerAlreadyInCluster = errors.New("Server already in Cluster") // memcached status ErrKeyNotFound = NewStatusError(errors.New("Key not found")) ErrKeyExists = NewStatusError(errors.New("Key exists")) ErrValueTooLarge = NewStatusError(errors.New("Value too large")) ErrItemNotStored = NewStatusError(errors.New("Item not stored")) ErrNoNumericValue = NewStatusError(errors.New("Incr/Decr on non-numeric value")) ErrVbucketNotFound = NewStatusError(errors.New("The vbucket belongs to another server")) ErrAuthFailed = NewStatusError(errors.New("Authentication error")) ErrAuthContinue = NewStatusError(errors.New("Authentication continue")) ErrUnknownCommand = NewStatusError(errors.New("Unknown command")) ErrOutOfMemory = NewStatusError(errors.New("Out of memory")) ErrNotSupported = NewStatusError(errors.New("Not supported")) ErrInternalError = NewStatusError(errors.New("Internal error")) ErrBusy = NewStatusError(errors.New("Internal error")) ErrTemporaryFailure = NewStatusError(errors.New("Temporary failure")) ErrUnmarshalFailed = NewStatusError(errors.New("Unmarshal value failed")) ErrMarshalFailed = NewStatusError(errors.New("Marshal value failed")) ErrCommandArgumentsInvalid = NewStatusError(errors.New("Command arguments invalid")) ErrTypeInvalid = NewStatusError(errors.New("Type invalid")) )
View Source
var (
HashCRC32Table = crc32.MakeTable(crc32.IEEE)
)
Functions ¶
func KetamaHash ¶
func WriteUint16 ¶
func WriteUint16(buffer *ByteBuffer, value uint16)
func WriteUint32 ¶
func WriteUint32(buffer *ByteBuffer, value uint32)
func WriteUint64 ¶
func WriteUint64(buffer *ByteBuffer, value uint64)
Types ¶
type Client ¶
type Client interface { // Add a memcached server. AddServer(addr string, maxConnPerServer uint32) error // Set callback when memcached server failed. // The callback's parameter is server address. SetServerErrorCallback(errCall ServerErrorCallback) // Exit client by manual control. // In theory that client will not be available after this function is called. Exit() // Get the value of key. // `value` is a pointer to a value variable. // Return value is the CAS corresponding to the key, // the error is nil when the operation is successful. Get(key string, value interface{}) (uint64, error) // Set the value of key. // Return value is the CAS corresponding to the key, // the error is nil when operation is successful. Set(args *KeyArgs) (uint64, error) // Same as `Set`. // When increase or decrease part of the data, must use this function. // Return value is CAS, // the error is nil when operation is successful, the function does not serialize data. SetRawData(args *KeyArgs) (uint64, error) // Add the value of key. // Return value is CAS, the error is nil when operation is successful. Add(args *KeyArgs) (uint64, error) // Same as `Add`. // When increase or decrease part of the data, must use this function. AddRawData(args *KeyArgs) (uint64, error) // Replace the value of key. // Return value is CAS, the error is nil when operation is successful. Replace(args *KeyArgs) (uint64, error) // Same as `Replace` // When increase or decrease part of the data, must use this function. ReplaceRawData(args *KeyArgs) (uint64, error) // Appends data to the tail/head of an existing value. // Return value is the CAS, and the error is nil when the operation is successful. // This function does not serialize data Append(args *KeyArgs) (uint64, error) Prepend(args *KeyArgs) (uint64, error) // Atomic operation, the delta of the existing value is increased/decreased. // If the key does not exist, the operation returns the initial value of the key. // The error is nil when the operation is successful Increment(args *KeyArgs) (uint64, uint64, error) Decrement(args *KeyArgs) (uint64, uint64, error) // Returns the current value of an atom. // The error is nil when the operation is successful TouchAtomicValue(key string) (uint64, error) // Flush all items, // flush the items in the cache now or some time in the future as specified by the expiration field Flush(args *KeyArgs) error }
func NewMemcachedClient ¶
type Cluster ¶
func (*Cluster) AddServer2Cluster ¶
func (*Cluster) ChooseServerCommanderByKey ¶
func (*Cluster) ChooseServerCommanderByServerAddr ¶
func (*Cluster) ReleaseServerCommander ¶
type CodecDecoder ¶
type CodecDecoder struct {
// contains filtered or unexported fields
}
func (*CodecDecoder) Decode ¶
func (decoder *CodecDecoder) Decode(data []byte, v interface{}) error
type CodecEncoder ¶
type CodecEncoder struct {
// contains filtered or unexported fields
}
func (*CodecEncoder) Encode ¶
func (encoder *CodecEncoder) Encode(v interface{}) ([]byte, error)
encoder := GetEncoder() data, err := encoder.Encode(v) PutEncoder(encoder) use data....
Dont do this, must put encoder to pool after data(new slice from encodeBuffer) use completed to avoid data conflict
type MemcachedClient ¶
type MemcachedClient struct {
// contains filtered or unexported fields
}
func (*MemcachedClient) AddRawData ¶
func (m *MemcachedClient) AddRawData(args *KeyArgs) (uint64, error)
func (*MemcachedClient) AddServer ¶
func (m *MemcachedClient) AddServer(addr string, maxConnPerServer uint32) error
func (*MemcachedClient) Decrement ¶
func (m *MemcachedClient) Decrement(args *KeyArgs) (uint64, uint64, error)
func (*MemcachedClient) Exit ¶
func (m *MemcachedClient) Exit()
func (*MemcachedClient) Flush ¶
func (m *MemcachedClient) Flush(args *KeyArgs) error
func (*MemcachedClient) Get ¶
func (m *MemcachedClient) Get(key string, value interface{}) (uint64, error)
func (*MemcachedClient) Increment ¶
func (m *MemcachedClient) Increment(args *KeyArgs) (uint64, uint64, error)
func (*MemcachedClient) ReplaceRawData ¶
func (m *MemcachedClient) ReplaceRawData(args *KeyArgs) (uint64, error)
func (*MemcachedClient) SetRawData ¶
func (m *MemcachedClient) SetRawData(args *KeyArgs) (uint64, error)
func (*MemcachedClient) SetServerErrorCallback ¶
func (m *MemcachedClient) SetServerErrorCallback(errCall ServerErrorCallback)
func (*MemcachedClient) TouchAtomicValue ¶
func (m *MemcachedClient) TouchAtomicValue(key string) (uint64, error)
type RequestHeader ¶
type ServerErrorCallback ¶
type ServerErrorCallback func(addr string)
type StatusError ¶
type StatusError struct {
Err error
}
func NewStatusError ¶
func NewStatusError(err error) *StatusError
func (*StatusError) Error ¶
func (s *StatusError) Error() string
func (*StatusError) Is ¶
func (s *StatusError) Is(err error) bool
func (*StatusError) Unwrap ¶
func (s *StatusError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.