cache

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 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] struct {
	// contains filtered or unexported fields
}

func (*Cache[T]) Delete

func (s *Cache[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 (*Cache[T]) Get

func (s *Cache[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 (*Cache[T]) Set

func (s *Cache[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.

Jump to

Keyboard shortcuts

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