cache

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultL1Expiration = 10 //10sec
View Source
var DefaultL1Size = 100 * 1024 * 1024 //100MB
View Source
var DefaultL2Expiration int32 = 300 //60sec
View Source
var ErrNotFound = errors.New("key not found in cache")
View Source
var None = &NoneCache{}

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Use(key string, getter func() (interface{}, error), result interface{}) (err error)
	Invalidate(key string) (err error)
}

type CacheConfig

type CacheConfig struct {
	L1Expiration   int
	L1Size         int
	L2Expiration   int32
	L2MemcacheUrls []string
}

type Item

type Item struct {
	Key   string
	Value []byte
}

type LayeredCache

type LayeredCache struct {
	Debug bool
	// contains filtered or unexported fields
}

func New

func New(config *CacheConfig) (result *LayeredCache)

func (*LayeredCache) Get

func (this *LayeredCache) Get(key string) (item Item, err error)

func (*LayeredCache) Invalidate

func (this *LayeredCache) Invalidate(key string) (err error)

func (*LayeredCache) Set

func (this *LayeredCache) Set(key string, value []byte)

func (*LayeredCache) Use

func (this *LayeredCache) Use(key string, getter func() (interface{}, error), result interface{}) (err error)

type NoneCache

type NoneCache struct{}

func (*NoneCache) Invalidate

func (this *NoneCache) Invalidate(key string) (err error)

func (*NoneCache) Use

func (this *NoneCache) Use(key string, getter func() (interface{}, error), result interface{}) (err error)

Jump to

Keyboard shortcuts

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