cache

package
v0.0.0-...-9a83fbb Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(cache Cache, key string)

func Exists

func Exists(cache Cache, key string) bool

func GetBool

func GetBool(cache Cache, key string) (bool, bool)

func GetString

func GetString(cache Cache, key string) (string, bool)

func SetBool

func SetBool(cache Cache, key string, v bool)

func SetString

func SetString(cache Cache, key string, v string)

Types

type Cache

type Cache interface {
	Get(key string, v any) bool
	Set(key string, value any)
	Delete(key string)
	Exists(key string) bool
}

func Create

func Create(lifeWindow time.Duration) Cache

func GetCache

func GetCache() Cache

func New

func New(options *CacheOptions) Cache

创建一个缓存对象

type CacheFactory

type CacheFactory interface {
	Create(options *CacheOptions) Cache
}

type CacheOptions

type CacheOptions struct {
	// 存活时长
	LifeWindow time.Duration
}

Jump to

Keyboard shortcuts

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