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: 0

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