Documentation
¶
Index ¶
- Constants
- Variables
- func Copy(src interface{}) interface{}
- func CopyInterface(input interface{}, result interface{}) error
- func CopyRecursive(original, cpy reflect.Value)
- func DefaultDecoder(input interface{}, result interface{}) (err error)
- func DefaultEncoder(input interface{}) (result interface{}, err error)
- func DefaultTTL(ttl *time.Duration) time.Duration
- func GetCacheKey(prefix string, key string) string
- func GetPointer(value interface{}) interface{}
- func GetValue(pointer interface{}) interface{}
- func Iface(iface interface{}) interface{}
- func ShakeTime10(t time.Duration) time.Duration
- type CacheStatus
- type CleanCacheHandler
- type Decoder
- type DecoderType
- type Encoder
- type GetCacheHandler
- type Interface
- type LC
- type MLCache
- type MemoryDBReader
- type Opt
- type SetCacheHandler
- type SimpleCallback
- type SimpleOpt
- type SimpleReader
Constants ¶
View Source
const ( LevelL1 = "L1" LevelL2 = "L2" LevelL3 = "L3" )
View Source
const DefaultRetryTime = 3
Variables ¶
View Source
var ( ErrInOutNotPointer = ecode.NewV2(-1, "input and result must be pointers") ErrInOutNotSameType = ecode.NewV2(-1, "input and result must have the same type") ErrOutFieldNotSettable = ecode.NewV2(-1, "result field is not settable") )
View Source
var ( ErrNotFound = ecode.NewV2(-1, "not found") ErrSetHandleNotFound = ecode.NewV2(-1, "set handler not found") ErrCleanHanderNotFound = ecode.NewV2(-1, "clean handler not found") ErrInputNotString = ecode.NewV2(-1, "input is not string") )
View Source
var (
ErrInNotString = ecode.NewV2(-1, "input is not string")
)
Functions ¶
func Copy ¶
func Copy(src interface{}) interface{}
Copy creates a deep copy of whatever is passed to it and returns the copy in an interface{}. The returned value will need to be asserted to the correct type.
func CopyInterface ¶
func CopyInterface(input interface{}, result interface{}) error
func CopyRecursive ¶
CopyRecursive does the actual copying of the interface. It currently has limited support for what it can handle. Add as needed.
func DefaultDecoder ¶
func DefaultDecoder(input interface{}, result interface{}) (err error)
func DefaultEncoder ¶
func DefaultEncoder(input interface{}) (result interface{}, err error)
func GetCacheKey ¶
func GetPointer ¶
func GetPointer(value interface{}) interface{}
Types ¶
type CacheStatus ¶
type DecoderType ¶
type GetCacheHandler ¶
type Interface ¶
type Interface interface {
DeepCopy() interface{}
}
Interface for delegating copy process to type
type LC ¶
type LC struct { Name string LevelName string // retry times when get/set handler failed Retry int GetCacheHandler GetCacheHandler SetCacheHandler SetCacheHandler CleanCacheHandler CleanCacheHandler // encoder and decoder Encoder Encoder Decoder Decoder }
type MLCache ¶
type MLCache interface { // TODO: support context Set(ctx context.Context, key string, val interface{}, opt ...Opt) error SetL2(ctx context.Context, key string, val interface{}, opt ...Opt) error Get(ctx context.Context, key string, val interface{}, opt ...Opt) (CacheStatus, error) Clean(ctx context.Context, key string) error }
type MemoryDBReader ¶
type MemoryDBReader struct {
// contains filtered or unexported fields
}
func NewMemoryDBReader ¶
func NewMemoryDBReader(client *ristrettoStore.RistrettoStore, callback SimpleCallback, simpleOpt ...SimpleOpt) *MemoryDBReader
NewMemoryDBReader callback中val需要是指针类型,如&[]*struct{} 先读redis缓存,如果没有再读取callback,然后写入redis缓存 redis key存储格式是 cacheKeyPrefix:{key}
func (*MemoryDBReader) Delete ¶
func (m *MemoryDBReader) Delete(ctx context.Context, key string) error
func (*MemoryDBReader) Get ¶
func (m *MemoryDBReader) Get(ctx context.Context, key string, value interface{}, opt ...Opt) (CacheStatus, error)
type Opt ¶
func DefaultOpt ¶
type SetCacheHandler ¶
type SimpleCallback ¶
SimpleCallback 读mysql/mongodb等数据库 or 其他io
type SimpleReader ¶
type SimpleReader struct {
// contains filtered or unexported fields
}
func NewSimpleReader ¶
func NewSimpleReader(client *redis.Client, callback SimpleCallback, simpleOpt ...SimpleOpt) *SimpleReader
NewSimpleReader 需要传入指针类型,如&[]*struct{} 先读redis缓存,如果没有再读取callback,然后写入redis缓存 redis key存储格式是 cacheKeyPrefix:{key}
func (*SimpleReader) Get ¶
func (m *SimpleReader) Get(ctx context.Context, key string, value interface{}, opt ...Opt) (CacheStatus, error)
Click to show internal directories.
Click to hide internal directories.