ccache

package
v0.0.0-...-5416f79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2017 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDataCache

func NewDataCache(config DataCacheConfig) *ccache.Cache

Set-up the data cache

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

type CacheCtrl struct {
	*ccache.Cache
}

Used to indicate the controller that it should not put the object into cache

func NewCacheCtrl

func NewCacheCtrl(cache *ccache.Cache) *CacheCtrl

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 (cc *CacheCtrl) MustFetchAndDoNotCacheEmpty(
	key string, duration time.Duration,
	fetch func() interface{},
) *ccache.Item

func (*CacheCtrl) MustFetchNative

func (cc *CacheCtrl) MustFetchNative(
	key string, duration time.Duration,
	fetch func() interface{},
) interface{}

func (*CacheCtrl) MustFetchNativeAndDoNotCacheEmpty

func (cc *CacheCtrl) MustFetchNativeAndDoNotCacheEmpty(
	key string, duration time.Duration,
	fetch func() interface{},
) interface{}

type CacheSetup

type CacheSetup func(config *ccache.Configuration)

type DataCacheConfig

type DataCacheConfig struct {
	MaxSize  int64
	Duration time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL