Documentation ¶
Index ¶
- func NewDataCache(config DataCacheConfig) *ccache.Cache
- func NewDataCacheWithSetup(config DataCacheConfig, setup CacheSetup) *ccache.Cache
- type CacheCtrl
- func (cc *CacheCtrl) MustFetch(key string, duration time.Duration, fetch func() interface{}) *ccache.Item
- func (cc *CacheCtrl) MustFetchAndDoNotCacheEmpty(key string, duration time.Duration, fetch func() interface{}) *ccache.Item
- func (cc *CacheCtrl) MustFetchNative(key string, duration time.Duration, fetch func() interface{}) interface{}
- func (cc *CacheCtrl) MustFetchNativeAndDoNotCacheEmpty(key string, duration time.Duration, fetch func() interface{}) interface{}
- type CacheSetup
- type DataCacheConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDataCacheWithSetup ¶
func NewDataCacheWithSetup(config DataCacheConfig, setup CacheSetup) *ccache.Cache
Sets-up the data cache with setup function, which you can override the configuration of Ccache
By default, this function would set buckets with following rules:
MaxSize <= 100 - 1 bucket MaxSize <= 500 - 2 bucket MaxSize <= 2000 - 4 bucket MaxSize <= 8000 - 8 bucket MaxSize > 8000 - 16 bucket
The one eighths of MaxSize would be ItemsToPrune
Types ¶
type CacheCtrl ¶
Used to indicate the controller that it should not put the object into cache
func NewCacheCtrl ¶
func (*CacheCtrl) MustFetch ¶
func (cc *CacheCtrl) MustFetch( key string, duration time.Duration, fetch func() interface{}, ) *ccache.Item
Fetchs object with panic if there is error occurred
nil value wouldn't be fetched
func (*CacheCtrl) MustFetchAndDoNotCacheEmpty ¶
func (*CacheCtrl) MustFetchNative ¶
type CacheSetup ¶
type CacheSetup func(config *ccache.Configuration)
type DataCacheConfig ¶
Click to show internal directories.
Click to hide internal directories.