Documentation ¶
Index ¶
- Constants
- Variables
- func BatchDbInsertExtractData(dataMake map[string]interface{}) (taskId int64, table string, data map[string]interface{})
- func BatchDbInsertMakeData(table string, data map[string]interface{}) (dataMake map[string]interface{})
- func BatchGetResultErr(m map[string]interface{}) (err error)
- func BatchGetResultVal(m map[string]interface{}) (val interface{})
- func BatchKvGetExtractData(dataMake map[string]interface{}) (taskId int64, key string, dataType int)
- func BatchKvGetMakeData(key string, dataType int) (dataMake map[string]interface{})
- func BatchKvSetExtractData(dataMake map[string]interface{}) (taskId int64, key string, val string, dataType int, onlySync bool, ...)
- func BatchKvSetMakeData(key, val string, dataType int, onlySync bool, breakDown bool) (dataMake map[string]interface{})
- func BatchResultErr(m map[string]interface{}, err error)
- func BatchResultVal(m map[string]interface{}, val interface{})
- func BatchTaskId(dataMake map[string]interface{}) int64
- func ByteToStr(b []byte) string
- func CacheDbGet(cacheType string, dataType int, table string, key string, order string, ...) (value map[string]interface{}, err error)
- func CacheDbInsert(cacheType string, dataType int, table string, data map[string]interface{}, ...) (err error)
- func CacheDbPreload(tableName string, keyName string, dataType int, maxNum int)
- func CacheDbUpdate(cacheType string, table string, data map[string]interface{}, key string, ...) (err error)
- func CacheExtractKey(key string) (keyPrefix string, keySuffix string)
- func CacheGet(cacheType string, dataType int, table string, key string, order string, ...) (value map[string]interface{}, err error)
- func CacheKeyInfo(key string) (src string, keyVal string, keyPrefix string)
- func CacheLocalRate() float64
- func CacheMakeKey(keyName string, value interface{}) string
- func CacheRebuild(maxNum int)
- func CacheRefreshForce(cacheType string, dataType int, table string, key string, query interface{}, ...)
- func CacheRemoteRate() float64
- func CacheResetLocalRate()
- func CacheResetRemoteRate()
- func CacheSyncStart()
- func CacheTimeout(breakDown bool, cacheType int) time.Duration
- func Init(options ...CacheOptionFunc) (err error)
- func MakeIdUnique() int64
- func RecoverCommon()
- func SelectDbMu() int
- func SelectQueue() int
- func Str2Byte(s string) (b []byte)
- type Batch
- type BatchCommon
- type BatchDbInsert
- type BatchKvCommon
- type BatchKvGet
- type BatchKvSet
- type BatchMemCommon
- type BatchMemGet
- type BatchMemSet
- type CacheOp
- type CacheOption
- type CacheOptionFunc
- func SetBatchCommitMinNumDb(minNum int) CacheOptionFunc
- func SetBatchCommitMinNumKv(minNum int) CacheOptionFunc
- func SetBatchCommitTimeoutMsDb(ms int) CacheOptionFunc
- func SetBatchCommitTimeoutMsKv(ms int) CacheOptionFunc
- func SetBreakDownTimeoutMs(ms int) CacheOptionFunc
- func SetBufferNum(num int) CacheOptionFunc
- func SetCacheSync(sync CacheSync) CacheOptionFunc
- func SetDb(db DbOp) CacheOptionFunc
- func SetDbLockTimeoutMs(ms int) CacheOptionFunc
- func SetDbMaxParallel(dbMaxParallel int) CacheOptionFunc
- func SetExpirationKvSeconds(seconds int) CacheOptionFunc
- func SetExpirationMemSeconds(seconds int) CacheOptionFunc
- func SetKeyPrefixSrc(m map[string]string) CacheOptionFunc
- func SetKv(kv CacheOp) CacheOptionFunc
- func SetMem(mem CacheOp) CacheOptionFunc
- func SetPriorities(priority ...int) CacheOptionFunc
- func SetQueueNum(num int) CacheOptionFunc
- type CacheStat
- type CacheSync
- type DbOp
- type KeyInfo
- type KeyValSetInfo
- type MutexTimeout
Constants ¶
View Source
const ( DefaultExpirationKvSeconds = 3600 DefaultExpirationMemSeconds = 3600 DefaultBatchCommitTimeoutMsDb = 10 DefaultBatchCommitMinNumDb = 10 DefaultBatchCommitTimeoutMsKv = 10 DefaultBatchCommitMinNumKv = 10 DefaultBufferNum = 1000 DefaultQueueNum = 10 DefaultDbMaxParallel = 15 DefaultDbLockTimeoutMs = 50 )
View Source
const ( CacheTypeMemory = 1 CacheTypeKv = 2 )
View Source
const ( DataTypeSingle = 1 DataTypeList = 2 )
View Source
const (
PublishMemChannel = "pub_mem"
)
Variables ¶
View Source
var ( ErrInitKvOpInvalid = fmt.Errorf("init kv op invalid") ErrInitDbOpInvalid = fmt.Errorf("init db op invalid") ErrInitMemOpInvalid = fmt.Errorf("init mem op invalid") ErrPriorityInvalid = fmt.Errorf("priority invalid") ErrNotExist = fmt.Errorf("not exist") ErrInitCacheSyncInvalid = fmt.Errorf("init cache sync invalid") )
View Source
var ( CacheTypeNameMap = map[int]string{ CacheTypeMemory: "memory", CacheTypeKv: "kv", } )
View Source
var ( CacheTypePriMap = map[string][]int{ "local": {CacheTypeMemory}, "remote": {CacheTypeKv}, "all": {CacheTypeMemory, CacheTypeKv}, } )
Functions ¶
func BatchDbInsertMakeData ¶
func BatchGetResultErr ¶
func BatchGetResultVal ¶
func BatchGetResultVal(m map[string]interface{}) (val interface{})
func BatchKvGetExtractData ¶
func BatchKvGetMakeData ¶
func BatchKvSetExtractData ¶
func BatchKvSetMakeData ¶
func BatchResultErr ¶
func BatchResultVal ¶
func BatchResultVal(m map[string]interface{}, val interface{})
func BatchTaskId ¶
func CacheDbGet ¶
func CacheDbInsert ¶
func CacheDbPreload ¶
缓存预热
func CacheDbUpdate ¶
func CacheExtractKey ¶
func CacheLocalRate ¶
func CacheLocalRate() float64
func CacheMakeKey ¶
func CacheRefreshForce ¶
func CacheRemoteRate ¶
func CacheRemoteRate() float64
func CacheResetLocalRate ¶
func CacheResetLocalRate()
func CacheResetRemoteRate ¶
func CacheResetRemoteRate()
func CacheSyncStart ¶
func CacheSyncStart()
func Init ¶
func Init(options ...CacheOptionFunc) (err error)
func MakeIdUnique ¶
func MakeIdUnique() int64
func RecoverCommon ¶
func RecoverCommon()
func SelectDbMu ¶
func SelectDbMu() int
func SelectQueue ¶
func SelectQueue() int
Types ¶
type BatchCommon ¶
type BatchDbInsert ¶
type BatchDbInsert struct {
// contains filtered or unexported fields
}
func NewBatchDbInsert ¶
func NewBatchDbInsert() (obj *BatchDbInsert)
func (*BatchDbInsert) AddTask ¶
func (b *BatchDbInsert) AddTask(data map[string]interface{}) (res map[string]interface{})
func (*BatchDbInsert) RunAsync ¶
func (b *BatchDbInsert) RunAsync()
type BatchKvCommon ¶
type BatchKvCommon struct { }
func NewBatchKvCommon ¶
func NewBatchKvCommon() *BatchKvCommon
type BatchKvGet ¶
type BatchKvGet struct {
// contains filtered or unexported fields
}
func NewBatchKvGet ¶
func NewBatchKvGet() (obj *BatchKvGet)
func (*BatchKvGet) AddTask ¶
func (b *BatchKvGet) AddTask(data map[string]interface{}) (res map[string]interface{})
func (*BatchKvGet) RunAsync ¶
func (b *BatchKvGet) RunAsync()
type BatchKvSet ¶
type BatchKvSet struct {
// contains filtered or unexported fields
}
func NewBatchKvSet ¶
func NewBatchKvSet() (obj *BatchKvSet)
func (*BatchKvSet) AddTask ¶
func (b *BatchKvSet) AddTask(data map[string]interface{}) (res map[string]interface{})
func (*BatchKvSet) RunAsync ¶
func (b *BatchKvSet) RunAsync()
type BatchMemCommon ¶
type BatchMemCommon struct { }
func NewBatchMemCommon ¶
func NewBatchMemCommon() *BatchMemCommon
type BatchMemGet ¶
type BatchMemGet struct { }
func NewBatchMemGet ¶
func NewBatchMemGet() *BatchMemGet
func (*BatchMemGet) AddTask ¶
func (b *BatchMemGet) AddTask(data map[string]interface{}) (res map[string]interface{})
func (*BatchMemGet) RunAsync ¶
func (b *BatchMemGet) RunAsync()
type BatchMemSet ¶
type BatchMemSet struct { }
func NewBatchMemSet ¶
func NewBatchMemSet() *BatchMemSet
func (*BatchMemSet) AddTask ¶
func (b *BatchMemSet) AddTask(data map[string]interface{}) (res map[string]interface{})
func (*BatchMemSet) RunAsync ¶
func (b *BatchMemSet) RunAsync()
type CacheOption ¶
type CacheOption struct {
// contains filtered or unexported fields
}
type CacheOptionFunc ¶
type CacheOptionFunc func(*CacheOption) error
func SetBatchCommitMinNumDb ¶
func SetBatchCommitMinNumDb(minNum int) CacheOptionFunc
func SetBatchCommitMinNumKv ¶
func SetBatchCommitMinNumKv(minNum int) CacheOptionFunc
func SetBatchCommitTimeoutMsDb ¶
func SetBatchCommitTimeoutMsDb(ms int) CacheOptionFunc
func SetBatchCommitTimeoutMsKv ¶
func SetBatchCommitTimeoutMsKv(ms int) CacheOptionFunc
func SetBreakDownTimeoutMs ¶
func SetBreakDownTimeoutMs(ms int) CacheOptionFunc
func SetBufferNum ¶
func SetBufferNum(num int) CacheOptionFunc
func SetCacheSync ¶
func SetCacheSync(sync CacheSync) CacheOptionFunc
func SetDb ¶
func SetDb(db DbOp) CacheOptionFunc
func SetDbLockTimeoutMs ¶
func SetDbLockTimeoutMs(ms int) CacheOptionFunc
func SetDbMaxParallel ¶
func SetDbMaxParallel(dbMaxParallel int) CacheOptionFunc
func SetExpirationKvSeconds ¶
func SetExpirationKvSeconds(seconds int) CacheOptionFunc
func SetExpirationMemSeconds ¶
func SetExpirationMemSeconds(seconds int) CacheOptionFunc
func SetKeyPrefixSrc ¶
func SetKeyPrefixSrc(m map[string]string) CacheOptionFunc
func SetKv ¶
func SetKv(kv CacheOp) CacheOptionFunc
func SetMem ¶
func SetMem(mem CacheOp) CacheOptionFunc
func SetPriorities ¶
func SetPriorities(priority ...int) CacheOptionFunc
func SetQueueNum ¶
func SetQueueNum(num int) CacheOptionFunc
type CacheStat ¶
type CacheStat struct { CacheNumLocal int64 CacheNumRemote int64 LastRateLocal float64 LastRateRemote float64 RequestsNumLocal int64 RequestsNumRemote int64 }
func (*CacheStat) RateRemote ¶
func (*CacheStat) ResetLocal ¶
func (s *CacheStat) ResetLocal()
func (*CacheStat) ResetRemote ¶
func (s *CacheStat) ResetRemote()
type CacheSync ¶
type CacheSync interface {
Subscribe() (chan KeyValSetInfo, error)
}
type DbOp ¶
type DbOp interface { InsertBatch(table string, data []map[string]interface{}) (err error) Get(table string, order string, query interface{}, args ...interface{}) (value []map[string]interface{}, err error) Update(table string, data map[string]interface{}, query interface{}, args ...interface{}) (err error) GetPage(table string, offset int, limit int) ([]map[string]interface{}, error) }
type KeyValSetInfo ¶
type MutexTimeout ¶
type MutexTimeout struct {
// contains filtered or unexported fields
}
func NewMutexTimeout ¶
func NewMutexTimeout() (mu *MutexTimeout)
func (*MutexTimeout) LockTimeout ¶
func (m *MutexTimeout) LockTimeout(d time.Duration) bool
func (*MutexTimeout) Unlock ¶
func (m *MutexTimeout) Unlock()
Click to show internal directories.
Click to hide internal directories.