cache

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: LGPL-3.0 Imports: 1 Imported by: ? modules, 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 struct {
	// contains filtered or unexported fields
}

Cache implements a thread safe cache

func NewCache

func NewCache() (*Cache, error)

NewCache constructs an cache instance

func (*Cache) Add

func (c *Cache) Add(key, value interface{}) bool

Add adds a value to the cache, return false if the entry already exists in cache and update the value

func (*Cache) Contains

func (c *Cache) Contains(key interface{}) (ok bool)

Contains checks if a key is in the cache, without return the value related to the key

func (*Cache) Get

func (c *Cache) Get(key interface{}) (interface{}, bool)

Get looks up a key's value from the cache.

func (*Cache) Keys

func (c *Cache) Keys() []interface{}

Keys returns a slice of the keys in the cache, out of the order

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Purge

func (c *Cache) Purge()

Purge is used to completely clear the cache

func (*Cache) Remove

func (c *Cache) Remove(key interface{}) bool

Remove removes the provided key from the cache, return true if the key was contained.

func (*Cache) RemoveWithCond

func (c *Cache) RemoveWithCond(key interface{}, fn cond) bool

RemoveWithCond removes elements if their keys are equal to the provided key according to fn

Jump to

Keyboard shortcuts

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