pokecache

package
v0.0.0-...-3955564 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 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 Cache

type Cache struct {
	Data map[string]CacheEntry
	sync.Mutex
}

cache type has a mutex to control access in goroutines

func NewCache

func NewCache(interval time.Duration) *Cache

function to create cache, accepts a interval parameter that will be used to clear the cache

func (*Cache) Add

func (c *Cache) Add(key string, val structs.Resource)

method to add a cacheEntry to cache

func (*Cache) Get

func (c *Cache) Get(key string) (structs.Resource, bool)

Get cache item

type CacheEntry

type CacheEntry struct {
	CreatedAt time.Time
	Val       structs.Resource
}

a cache entry

Jump to

Keyboard shortcuts

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