cache

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 2 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 interface {
	Get(k string) *Item
	Set(k string, x interface{})
	Delete(k string)
}

Cache stores, retrieves and deletes cacheable items

type Item added in v0.1.6

type Item struct {
	Object interface{}
	Age    int64
}

Item is an object which is stored in Cache

func (*Item) GetAge added in v0.1.6

func (i *Item) GetAge() time.Duration

Get age returns the age of the cached object

func (*Item) RefreshAge added in v0.1.6

func (i *Item) RefreshAge()

type MemoryCache

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

MemoryCache is an implemtation of Cache that will store items in an in-memory map

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache returns a new Cache that will store items in an in-memory map

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(k string)

Delete removes an item from cache

func (*MemoryCache) Get

func (c *MemoryCache) Get(k string) *Item

Get returns an item from cache

func (*MemoryCache) Refresh added in v0.1.6

func (c *MemoryCache) Refresh(k string)

func (*MemoryCache) Set

func (c *MemoryCache) Set(k string, x interface{})

Set stores an item to cache

Jump to

Keyboard shortcuts

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