memcache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const ObjectTooBigErrorMsg = "object too large for cache"

ObjectTooBigErrorMsg ...

Variables

View Source
var ErrAlreadyGotten = errors.New("pipeline error: already gotten")

ErrAlreadyGotten returns when the callback functions of MGet, MSet, etc. is called more than once

View Source
var ErrConnClosed = errors.New("memcache: connection closed")

ErrConnClosed ...

View Source
var ErrInvalidKeyFormat = errors.New("memcached: invalid key format")

ErrInvalidKeyFormat ...

View Source
var ErrInvalidMDel = ErrBrokenPipe{/* contains filtered or unexported fields */}

ErrInvalidMDel ...

View Source
var ErrInvalidMGet = ErrBrokenPipe{/* contains filtered or unexported fields */}

ErrInvalidMGet ...

View Source
var ErrInvalidMSet = ErrBrokenPipe{/* contains filtered or unexported fields */}

ErrInvalidMSet ...

View Source
var ErrInvalidResponse = ErrBrokenPipe{/* contains filtered or unexported fields */}

ErrInvalidResponse ...

View Source
var ErrKeyEmpty = errors.New("memcached: key is empty")

ErrKeyEmpty ...

View Source
var ErrKeyTooLong = errors.New("memcached: key too long")

ErrKeyTooLong ...

Functions

func IsServerError added in v0.5.5

func IsServerError(err error) bool

IsServerError ...

func NewClientError

func NewClientError(msg string) error

NewClientError ...

func NewServerError

func NewServerError(msg string) error

NewServerError ...

func ReleaseGetResponseData added in v1.2.0

func ReleaseGetResponseData(data []byte)

ReleaseGetResponseData store response data for reuse

func ReleaseMGetResult added in v1.2.0

func ReleaseMGetResult(r MGetResult)

ReleaseMGetResult puts back to pool for reuse

Types

type Client

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

Client ...

func New

func New(addr string, numConns int, options ...Option) (*Client, error)

New ...

func (*Client) Close added in v0.3.0

func (c *Client) Close() error

Close shut down Client

func (*Client) Pipeline

func (c *Client) Pipeline() *Pipeline

Pipeline creates a pipeline

type ErrBrokenPipe

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

ErrBrokenPipe ...

func (ErrBrokenPipe) Error

func (e ErrBrokenPipe) Error() string

type ErrClientError

type ErrClientError struct {
	Message string
}

ErrClientError ...

func (ErrClientError) Error

func (e ErrClientError) Error() string

type ErrServerError

type ErrServerError struct {
	Message string
}

ErrServerError ...

func (ErrServerError) Error

func (e ErrServerError) Error() string

type FlushWriter

type FlushWriter = netconn.FlushWriter

FlushWriter ...

type MDelOptions

type MDelOptions struct {
	CAS uint64
	I   bool   // set as stale instead of delete completely
	TTL uint32 // only apply if I = true
}

MDelOptions ...

type MDelResponse

type MDelResponse struct {
	Type MDelResponseType
}

MDelResponse ...

type MDelResponseType

type MDelResponseType int

MDelResponseType ...

const (
	// MDelResponseTypeHD ...
	MDelResponseTypeHD MDelResponseType = iota + 1 // DELETED
	// MDelResponseTypeNF ...
	MDelResponseTypeNF // NOT FOUND
	// MDelResponseTypeEX ...
	MDelResponseTypeEX // EXISTS, cas not match
)

type MGetFlags

type MGetFlags uint64

MGetFlags ...

const (
	// MGetFlagW ...
	MGetFlagW MGetFlags = 1 << iota // won cache lease
	// MGetFlagX ...
	MGetFlagX // stale data
	// MGetFlagZ ...
	MGetFlagZ // already has winning flag
)

type MGetOptions

type MGetOptions struct {
	N   uint32 // option N of mg command
	CAS bool
}

MGetOptions ...

type MGetResponse

type MGetResponse struct {
	Type  MGetResponseType
	Data  []byte
	Flags MGetFlags
	CAS   uint64
}

MGetResponse ...

type MGetResponseType

type MGetResponseType int

MGetResponseType ...

const (
	// MGetResponseTypeVA ...
	MGetResponseTypeVA MGetResponseType = iota + 1
	// MGetResponseTypeHD ...
	MGetResponseTypeHD
	// MGetResponseTypeEN ...
	MGetResponseTypeEN
)

type MGetResult added in v1.2.0

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

MGetResult ...

func (MGetResult) Result added in v1.2.0

func (r MGetResult) Result() (MGetResponse, error)

Result returns meta get response The field MGetResponse.Data SHOULD be released after use using function ReleaseGetResponseData for reuse memory space

type MSetOptions

type MSetOptions struct {
	CAS uint64
	TTL uint32
}

MSetOptions ...

type MSetResponse

type MSetResponse struct {
	Type MSetResponseType
}

MSetResponse ...

type MSetResponseType

type MSetResponseType int

MSetResponseType ...

const (
	// MSetResponseTypeHD ...
	MSetResponseTypeHD MSetResponseType = iota + 1 // STORED
	// MSetResponseTypeNS ...
	MSetResponseTypeNS // NOT STORED
	// MSetResponseTypeEX ...
	MSetResponseTypeEX // EXISTS, cas modified
	// MSetResponseTypeNF ...
	MSetResponseTypeNF // NOT FOUND, cas not found
)

type Option

type Option func(opts *memcacheOptions)

Option ...

func WithBufferSize added in v0.3.2

func WithBufferSize(size int) Option

WithBufferSize change receiving & sending buffer size

func WithDialErrorLogger added in v0.3.5

func WithDialErrorLogger(fn func(err error)) Option

WithDialErrorLogger set the dial error logger

func WithDialFunc added in v0.4.0

func WithDialFunc(dialFunc func(network, address string, timeout time.Duration) (net.Conn, error)) Option

WithDialFunc ...

func WithHealthCheckDuration added in v1.2.0

func WithHealthCheckDuration(duration time.Duration) Option

WithHealthCheckDuration specifies duration in which health check will be called after connections have no activity default is 15 seconds

func WithMaxCommandsPerBatch added in v1.1.0

func WithMaxCommandsPerBatch(maxCommands int) Option

WithMaxCommandsPerBatch specifies the number of commands each batch will contain, if a pipeline has more command than this value, it will be split to multiple commands to avoid starvation

func WithNetConnOptions added in v0.4.3

func WithNetConnOptions(options ...netconn.Option) Option

WithNetConnOptions ...

func WithRetryDuration

func WithRetryDuration(d time.Duration) Option

WithRetryDuration duration between TCP connection retry

func WithTCPKeepAliveDuration added in v0.3.4

func WithTCPKeepAliveDuration(d time.Duration) Option

WithTCPKeepAliveDuration sets the tcp keep alive duration

func WithWriteLimit added in v1.1.0

func WithWriteLimit(limit int) Option

WithWriteLimit limit the number of concurrent operations send to memcached on one go

type Pipeline

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

Pipeline should NOT be used concurrently

func (*Pipeline) Execute added in v0.3.0

func (p *Pipeline) Execute()

Execute flush operations to memcached (interrupts pipelining)

func (*Pipeline) Finish

func (p *Pipeline) Finish()

Finish ...

func (*Pipeline) FlushAll

func (p *Pipeline) FlushAll() func() error

FlushAll ...

func (*Pipeline) MDel

func (p *Pipeline) MDel(key string, opts MDelOptions) func() (MDelResponse, error)

MDel ...

func (*Pipeline) MGet

func (p *Pipeline) MGet(key string, opts MGetOptions) func() (MGetResponse, error)

MGet using the *mg* meta command of memcached The field MGetResponse.Data SHOULD be released after use using function ReleaseGetResponseData for reuse memory spaces

func (*Pipeline) MGetFast added in v1.2.0

func (p *Pipeline) MGetFast(key string, opts MGetOptions) (MGetResult, error)

MGetFast is similar to MGet, but without one more alloc The MGetResult returned SHOULD be released after use using ReleaseMGetResult

func (*Pipeline) MSet

func (p *Pipeline) MSet(key string, value []byte, opts MSetOptions) func() (MSetResponse, error)

MSet ...

func (*Pipeline) Version added in v1.2.0

func (p *Pipeline) Version() func() (VersionResponse, error)

Version ...

type VersionResponse added in v1.2.0

type VersionResponse struct {
	Version string
}

VersionResponse ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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