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: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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