Documentation ¶
Index ¶
- Variables
- type CallbackFunc
- type DeleteOptions
- type DeleteResponse
- type LeaseGetErrorResult
- type LeaseGetOptions
- type LeaseGetResponse
- type LeaseGetResult
- type LeaseGetResultFunc
- type LeaseGetStatus
- type LeaseSetOptions
- type LeaseSetResponse
- type LeaseSetStatus
- type Memcache
- type Pipeline
- type PipelineConfig
- type PipelineOption
- type PlainMemcacheOption
- type Session
- type SessionProvider
- type SessionProviderOption
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidLeaseGetResponse = errors.New("invalid lease get response")
ErrInvalidLeaseGetResponse ...
Functions ¶
This section is empty.
Types ¶
type CallbackFunc ¶ added in v1.1.0
CallbackFunc for session
func NewEmptyCallback ¶ added in v1.1.0
func NewEmptyCallback(fn func()) CallbackFunc
NewEmptyCallback creates CallbackFunc from empty args function
type LeaseGetErrorResult ¶ added in v1.1.0
type LeaseGetErrorResult struct {
Error error
}
LeaseGetErrorResult for error only result
func (LeaseGetErrorResult) Result ¶ added in v1.1.0
func (r LeaseGetErrorResult) Result() (LeaseGetResponse, error)
Result ...
type LeaseGetResponse ¶
type LeaseGetResponse struct { Status LeaseGetStatus CAS uint64 Data []byte }
LeaseGetResponse lease get response
type LeaseGetResult ¶ added in v1.1.0
type LeaseGetResult interface {
Result() (LeaseGetResponse, error)
}
LeaseGetResult is the response of LeaseGet, method Result MUST only be called Once. Calling Result more than once is undefined behaviour
type LeaseGetResultFunc ¶ added in v1.1.0
type LeaseGetResultFunc func() (LeaseGetResponse, error)
LeaseGetResultFunc for function implementation of LeaseGetResult
func (LeaseGetResultFunc) Result ¶ added in v1.1.0
func (f LeaseGetResultFunc) Result() (LeaseGetResponse, error)
Result ...
type LeaseGetStatus ¶
type LeaseGetStatus uint32
LeaseGetStatus status of lease get
const ( // LeaseGetStatusFound returns Data LeaseGetStatusFound LeaseGetStatus = iota + 1 // LeaseGetStatusLeaseGranted lease granted LeaseGetStatusLeaseGranted // LeaseGetStatusLeaseRejected lease rejected LeaseGetStatusLeaseRejected )
type LeaseSetResponse ¶
type LeaseSetResponse struct {
Status LeaseSetStatus
}
LeaseSetResponse lease set response
type LeaseSetStatus ¶
type LeaseSetStatus uint32
LeaseSetStatus ...
const ( // LeaseSetStatusStored ... LeaseSetStatusStored LeaseSetStatus = iota + 1 // LeaseSetStatusNotStored NOT stored because of key already been deleted or CAS has changed LeaseSetStatusNotStored )
type Memcache ¶
type Memcache interface { // Pipeline creates a Pipeline, a NON thread safe object Pipeline(ctx context.Context, options ...PipelineOption) Pipeline // Close shutdowns memcache client Close() error }
Memcache represents a generic Memcache interface implementations of this interface must be thread safe
func NewPlainMemcache ¶
func NewPlainMemcache( client *memcache.Client, options ...PlainMemcacheOption, ) Memcache
NewPlainMemcache a light wrapper around memcached client
type Pipeline ¶
type Pipeline interface { // LeaseGet should not be used directly, use the item or mmap package instead LeaseGet(key string, options LeaseGetOptions) LeaseGetResult LeaseSet(key string, data []byte, cas uint64, options LeaseSetOptions) func() (LeaseSetResponse, error) Delete(key string, options DeleteOptions) func() (DeleteResponse, error) // Execute flush commands to the network Execute() // Finish must be called after create a Pipeline, often by defer Finish() // LowerSession returns a lower priority session LowerSession() Session }
Pipeline represents a generic Pipeline
type PipelineConfig ¶
type PipelineConfig struct {
// contains filtered or unexported fields
}
PipelineConfig ...
func ComputePipelineConfig ¶
func ComputePipelineConfig(options []PipelineOption) *PipelineConfig
ComputePipelineConfig ...
func (*PipelineConfig) GetSession ¶
func (c *PipelineConfig) GetSession(provider SessionProvider) Session
GetSession ...
type PipelineOption ¶
type PipelineOption func(conf *PipelineConfig)
PipelineOption ...
func WithPipelineExistingSession ¶
func WithPipelineExistingSession(sess Session) PipelineOption
WithPipelineExistingSession ...
type PlainMemcacheOption ¶
type PlainMemcacheOption func(opts *plainMemcacheConfig)
PlainMemcacheOption ...
func WithPlainMemcacheLeaseDuration ¶
func WithPlainMemcacheLeaseDuration(leaseDurationSeconds uint32) PlainMemcacheOption
WithPlainMemcacheLeaseDuration ...
func WithPlainMemcacheSessionProvider ¶
func WithPlainMemcacheSessionProvider(sessProvider SessionProvider) PlainMemcacheOption
WithPlainMemcacheSessionProvider ...
type Session ¶
type Session interface { AddNextCall(fn CallbackFunc) AddDelayedCall(d time.Duration, fn CallbackFunc) Execute() GetLower() Session }
Session controlling session values & delayed tasks, this object is NOT Thread Safe
type SessionProvider ¶
type SessionProvider interface {
New() Session
}
SessionProvider for controlling delayed tasks, this object is Thread Safe
func NewSessionProvider ¶
func NewSessionProvider(options ...SessionProviderOption) SessionProvider
NewSessionProvider is THREAD SAFE
type SessionProviderOption ¶
type SessionProviderOption func(conf *sessionProviderConf)
SessionProviderOption ...
func WithSessionNowFunc ¶
func WithSessionNowFunc(nowFn func() time.Time) SessionProviderOption
WithSessionNowFunc ...
func WithSessionSleepFunc ¶
func WithSessionSleepFunc(sleepFn func(d time.Duration)) SessionProviderOption
WithSessionSleepFunc ...