Documentation ¶
Index ¶
- Constants
- Variables
- func IsServerError(err error) bool
- func NewClientError(msg string) error
- func NewServerError(msg string) error
- func ReleaseGetResponseData(data []byte)
- func ReleaseMGetResult(r MGetResult)
- type Client
- type ErrBrokenPipe
- type ErrClientError
- type ErrServerError
- type FlushWriter
- type MDelOptions
- type MDelResponse
- type MDelResponseType
- type MGetFlags
- type MGetOptions
- type MGetResponse
- type MGetResponseType
- type MGetResult
- type MSetOptions
- type MSetResponse
- type MSetResponseType
- type Option
- func WithBufferSize(size int) Option
- func WithDialErrorLogger(fn func(err error)) Option
- func WithDialFunc(...) Option
- func WithHealthCheckDuration(duration time.Duration) Option
- func WithMaxCommandsPerBatch(maxCommands int) Option
- func WithNetConnOptions(options ...netconn.Option) Option
- func WithRetryDuration(d time.Duration) Option
- func WithTCPKeepAliveDuration(d time.Duration) Option
- func WithWriteLimit(limit int) Option
- type Pipeline
- func (p *Pipeline) Execute()
- func (p *Pipeline) Finish()
- func (p *Pipeline) FlushAll() func() error
- func (p *Pipeline) MDel(key string, opts MDelOptions) func() (MDelResponse, error)
- func (p *Pipeline) MGet(key string, opts MGetOptions) func() (MGetResponse, error)
- func (p *Pipeline) MGetFast(key string, opts MGetOptions) (MGetResult, error)
- func (p *Pipeline) MSet(key string, value []byte, opts MSetOptions) func() (MSetResponse, error)
- func (p *Pipeline) Version() func() (VersionResponse, error)
- type VersionResponse
Constants ¶
const ObjectTooBigErrorMsg = "object too large for cache"
ObjectTooBigErrorMsg ...
Variables ¶
var ErrAlreadyGotten = errors.New("pipeline error: already gotten")
ErrAlreadyGotten returns when the callback functions of MGet, MSet, etc. is called more than once
var ErrConnClosed = errors.New("memcache: connection closed")
ErrConnClosed ...
var ErrInvalidKeyFormat = errors.New("memcached: invalid key format")
ErrInvalidKeyFormat ...
var ErrInvalidMDel = ErrBrokenPipe{/* contains filtered or unexported fields */}
ErrInvalidMDel ...
var ErrInvalidMGet = ErrBrokenPipe{/* contains filtered or unexported fields */}
ErrInvalidMGet ...
var ErrInvalidMSet = ErrBrokenPipe{/* contains filtered or unexported fields */}
ErrInvalidMSet ...
var ErrInvalidResponse = ErrBrokenPipe{/* contains filtered or unexported fields */}
ErrInvalidResponse ...
var ErrKeyEmpty = errors.New("memcached: key is empty")
ErrKeyEmpty ...
var ErrKeyTooLong = errors.New("memcached: key too long")
ErrKeyTooLong ...
Functions ¶
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 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 MDelOptions ¶
type MDelOptions struct { CAS uint64 I bool // set as stale instead of delete completely TTL uint32 // only apply if I = true }
MDelOptions ...
type MDelResponseType ¶
type MDelResponseType int
MDelResponseType ...
const ( // MDelResponseTypeHD ... MDelResponseTypeHD MDelResponseType = iota + 1 // DELETED // MDelResponseTypeNF ... MDelResponseTypeNF // NOT FOUND // MDelResponseTypeEX ... MDelResponseTypeEX // EXISTS, cas not match )
type MGetOptions ¶
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 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
WithBufferSize change receiving & sending buffer size
func WithDialErrorLogger ¶ added in v0.3.5
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
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
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
WithNetConnOptions ...
func WithRetryDuration ¶
WithRetryDuration duration between TCP connection retry
func WithTCPKeepAliveDuration ¶ added in v0.3.4
WithTCPKeepAliveDuration sets the tcp keep alive duration
func WithWriteLimit ¶ added in v1.1.0
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) 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 ...