cache

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cache 缓存 异步更新

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache 缓存

func New

func New(u UpdateMehtod) *Cache

New 创建一个Cache对象

func (*Cache) SetBlock

func (cache *Cache) SetBlock(is bool)

SetBlock 默认false

func (*Cache) SetOnError

func (cache *Cache) SetOnError(errFunc func(err interface{}))

SetOnError 默认false

func (*Cache) SetUpdateCond

func (cache *Cache) SetUpdateCond(method func() bool)

SetUpdateCond 设置cache更新的条件. 时间间隔更新失效

func (*Cache) SetUpdateInterval

func (cache *Cache) SetUpdateInterval(interval time.Duration)

SetUpdateInterval 设置cache更新的条件. 时间间隔更新. SetUpdateCond会失效. Cond也能完成所有更新方式

func (*Cache) SetUpdateMethod

func (cache *Cache) SetUpdateMethod(method UpdateMehtod)

SetUpdateMethod 设置cache更新方法

func (*Cache) Update

func (cache *Cache) Update()

Update 主动更新

func (*Cache) Value

func (cache *Cache) Value() interface{}

Value 获取缓存的值

type UpdateMehtod

type UpdateMehtod func() interface{}

UpdateMehtod 更新方法

Jump to

Keyboard shortcuts

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