cache

package
v2.14.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.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[T any] interface {
	Get(key string) (T, bool)
	Set(key string, entries T)
	Delete(key string)
}

type DefaultCache added in v2.6.0

type DefaultCache[T any] struct {
	// contains filtered or unexported fields
}

func (*DefaultCache[T]) Delete added in v2.6.0

func (s *DefaultCache[T]) Delete(key string)

Delete removes an entry from the cache with the specified key. It acquires an exclusive write lock to ensure exclusive access during the deletion.

func (*DefaultCache[T]) Get added in v2.6.0

func (s *DefaultCache[T]) Get(key string) (T, bool)

Get retrieves the value associated with the given key from the cache. It acquires a read lock to allow concurrent access from multiple goroutines. It returns the value and a boolean indicating if the value exists in the cache.

func (*DefaultCache[T]) Set added in v2.6.0

func (s *DefaultCache[T]) Set(key string, entries T)

Set adds or updates an entry in the cache with the specified key and value. It acquires an exclusive write lock to ensure exclusive access during the update.

type NoopCache added in v2.6.0

type NoopCache[T interface{}] struct{}

func (NoopCache[T]) Delete added in v2.6.0

func (n NoopCache[T]) Delete(_ string)

func (NoopCache[T]) Get added in v2.6.0

func (n NoopCache[T]) Get(_ string) (T, bool)

func (NoopCache[T]) Set added in v2.6.0

func (n NoopCache[T]) Set(_ string, _ T)

Jump to

Keyboard shortcuts

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