cache

package
v0.0.0-...-0985de9 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

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
}

这是为自己项目的缓存而设计的;

var CacheManager *Cache

func NewCache

func NewCache(cache CacheInterface) *Cache

func (*Cache) Clear

func (c *Cache) Clear() error

func (*Cache) Delete

func (c *Cache) Delete(key interface{}) error

func (*Cache) Get

func (c *Cache) Get(key interface{}) (interface{}, error)

func (*Cache) Set

func (c *Cache) Set(key, value interface{}, options *Options) error

type CacheInterface

type CacheInterface interface {
	Get(ctx context.Context, key interface{}) (interface{}, error)
	Set(ctx context.Context, key, object interface{}, options *store.Options) error
	Delete(ctx context.Context, key interface{}) error
	Clear(ctx context.Context) error
}

type Config

type Config struct {
	Default string
	Expire  int

	FreeCache struct {
		CacheSize  int
		Expiration int
	}
}

type FreeCache

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

func NewFreeCache

func NewFreeCache(cfg *Config) *FreeCache

func (*FreeCache) Clear

func (cache *FreeCache) Clear(ctx context.Context) error

func (*FreeCache) Delete

func (cache *FreeCache) Delete(ctx context.Context, key interface{}) error

func (*FreeCache) Get

func (cache *FreeCache) Get(ctx context.Context, key interface{}) (interface{}, error)

func (*FreeCache) Set

func (cache *FreeCache) Set(ctx context.Context, key, object interface{}, options *store.Options) error

type Options

type Options struct {
	Cost       int64
	Expiration time.Duration
	Tags       []string
}

属于自己当前的项目需要的options

Jump to

Keyboard shortcuts

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