memory_cache

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Forever = 87660 * time.Hour
View Source
const Infinite = math.MaxInt32

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(key string, value interface{}, ttl *time.Duration) error
	Get(key string) (interface{}, error)
	Remove(key string) error
	Truncate() error
	Len() int
	Size() uintptr
	Keys() []string
}

func New

func New() (Cache, error)

func NewWithOption

func NewWithOption(option Option) (Cache, error)

type Option

type Option struct {
	MaxEntrySize        int
	MaxEntriesKey       int
	MaxEntriesInWindow  int64
	MaxPercentageMemory float64
	OnRemove            func(key string, value interface{})
	OnRemoveWithReason  func(key string, reason string)
	OnMemoryExceed      func(memoryUsedPercentage float64, maxMemoryPercentage float64, memoryUsed float64)
}

Jump to

Keyboard shortcuts

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