cache

package
Version: v0.0.0-...-39cffea Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheTime = time.Minute
)

consts

View Source
const (
	DefaultMaxLen = 100000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Put(key Key, value Value)
	PutWithTimeout(key Key, value Value, t time.Duration)
	Get(key Key) (Value, bool)
	Del(key Key) Value
	Len() int
	Close()
}

func NewCache

func NewCache() Cache

NewCache will create a default configured cache

func NewCacheWithConfig

func NewCacheWithConfig(config Config) Cache

NewCacheWithConfig will create a cache with the configs

type Config

type Config struct {
	MaxLen    int
	Callback  OnEvicted
	CacheTime time.Duration
}

Config of the cache

type Key

type Key interface{}

type OnEvicted

type OnEvicted func(key Key, value Value)

OnEvicted callback func will be called when the cached key expired

type Value

type Value interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL