softcache

package module
v0.0.0-...-4ede2fd Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWaitTooLong = errors.New(`SoftCache - The transaction is not proceeded due to long waiting. `)

Functions

This section is empty.

Types

type CacheManager

type CacheManager struct {
	RedisClient *redis.Client          `inject:""`
	LockFactory *redisLock.LockFactory `inject:""`
	// contains filtered or unexported fields
}

func New

func New(
	cacheRefreshingLockPrefix string,
	listLockName string,
	listName string,
) *CacheManager

func (*CacheManager) AddCacheRefresher

func (cm *CacheManager) AddCacheRefresher(options CacheRefresherOptions) error

func (*CacheManager) GetData

func (cm *CacheManager) GetData(refresherID string, input string) (string, error)

func (*CacheManager) GetManagerLock

func (cm *CacheManager) GetManagerLock() *redisLock.Lock

func (*CacheManager) Refresh

func (cm *CacheManager) Refresh(refresherID, inputJSON string, isForceReload bool) error

func (*CacheManager) Start

func (cm *CacheManager) Start()

type CacheRefreshCallback

type CacheRefreshCallback interface {
	Refresh(input string) (string, error)
	GetName() string
}

type CacheRefresherOptions

type CacheRefresherOptions struct {
	Callback    CacheRefreshCallback
	TaskSetting *redisLock.LockOptions
	HardTtl     time.Duration // TTL set in Redis
	SoftTtl     time.Duration // TTL for SoftCache to refresh cache
}

func (CacheRefresherOptions) IsStillWithinSoftTTL

func (rs CacheRefresherOptions) IsStillWithinSoftTTL(ttl time.Duration) bool

Jump to

Keyboard shortcuts

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