Documentation ¶
Overview ¶
Package cachefetcher is the function cache fetcher for golang.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidKeyElements is invalid for setting key. ErrInvalidKeyElements = errors.New("cachefetcher: key elements is invalid") // ErrTimeout is singleflight's chan timeout. ErrTimeout = errors.New("cachefetcher: timeout") // ErrNoPointerType is Get's dst type is no pointer. ErrNoPointerType = errors.New("cachefetcher: no pointer type") // ErrGobSerialized failed to encode or decode of gob. ErrGobSerialized = errors.New("cachefetcher: gob serialized failed") )
Functions ¶
This section is empty.
Types ¶
type CacheFetcher ¶
type CacheFetcher interface { SetKey(prefixes []string, elements ...interface{}) error SetHashKey(prefixes []string, elements ...interface{}) error Key() string Fetch(expiration time.Duration, dst interface{}, fetcher interface{}) error Set(value interface{}, expiration time.Duration) error Get(dst interface{}) error SetString(value string, expiration time.Duration) error GetString() (string, error) Del() error GobRegister(value interface{}) IsCached() bool }
CacheFetcher have main module functions.
type Client ¶
type Client interface { Set(key string, value interface{}, expiration time.Duration) error Get(key string, dst interface{}) error Del(key string) error IsErrCacheMiss(err error) bool }
Client is needs implement.
type Factory ¶ added in v1.5.1
type Factory interface {
NewFetcher() CacheFetcher
}
CacheFetcher have main module functions.
func NewFactory ¶ added in v1.5.1
NewCacheFetcher is new method for CacheFetcher.
type Options ¶
type Options struct { Group *singleflight.Group GroupTimeout time.Duration DebugPrintMode bool IsNotSerialized bool // serialize default with using gob serializer. }
Options is extended settings.
type SimpleRedisClientImpl ¶ added in v1.3.0
type SimpleRedisClientImpl struct {
Rdb *redis.Client
}
SimpleRedisClientImpl is a sample redisClient implementation.
func (*SimpleRedisClientImpl) Del ¶ added in v1.3.0
func (i *SimpleRedisClientImpl) Del(key string) error
Del is an implementation of the function in the sample redisClient.
func (*SimpleRedisClientImpl) Get ¶ added in v1.3.0
func (i *SimpleRedisClientImpl) Get(key string, dst interface{}) error
Get is an implementation of the function in the sample redisClient.
func (*SimpleRedisClientImpl) IsErrCacheMiss ¶ added in v1.3.0
func (i *SimpleRedisClientImpl) IsErrCacheMiss(err error) bool
IsErrCacheMiss is an implementation of the function in the sample redisClient. Please return the decision at the time of cache miss err.
Click to show internal directories.
Click to hide internal directories.