memorycache

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 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 CacheTTL

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

CacheTTL is a cache source for on-memory cache When item size reaches maxSize, the item is selected by FIFO or TTL and erased.

func NewCacheTTL

func NewCacheTTL(max int) *CacheTTL

NewCacheTTL returns initialized CacheTTL max value limits maximum saved item size.

func (*CacheTTL) Clear added in v0.3.3

func (c *CacheTTL) Clear() error

Clear deletes all of cached data.

func (*CacheTTL) Get

func (c *CacheTTL) Get(key string, data interface{}) bool

Get searches cache on memory by given key and returns flag of cache is existed or not. when cache hit, data is assigned.

func (*CacheTTL) GetGobBytes

func (c *CacheTTL) GetGobBytes(key string) ([]byte, bool)

GetGobBytes searches cache on memory by given key and returns gob-encoded value.

func (*CacheTTL) GetInterface

func (c *CacheTTL) GetInterface(key string) (interface{}, bool)

GetInterface searches cache on memory by given key and returns interface value.

func (*CacheTTL) Set

func (c *CacheTTL) Set(key string, data interface{}) error

Set sets data.

func (*CacheTTL) SetExpire

func (c *CacheTTL) SetExpire(key string, data interface{}, ttl int64) error

SetExpire sets data with TTL.

func (*CacheTTL) SetTTL

func (c *CacheTTL) SetTTL(ttl int64)

SetTTL sets default TTL (milliseconds)

Jump to

Keyboard shortcuts

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