cache

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 3 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
}

Cache represents an in-memory cache.

func NewCache

func NewCache[T any]() *Cache[T]

NewCache creates a new instance of the cache.

func (*Cache[T]) Get

func (c *Cache[T]) Get(key string) (T, bool)

Get retrieves an item from the cache by its key.

func (*Cache[T]) GetAllKeys

func (c *Cache[T]) GetAllKeys() []string

func (*Cache[T]) Reset

func (c *Cache[T]) Reset()

func (*Cache[T]) Set

func (c *Cache[T]) Set(key string, value T, expiration time.Time)

Set adds an item to the cache with a specified key and expiration time.

type CacheItem

type CacheItem[T any] struct {
	Value      T
	Expiration time.Time
}

CacheItem represents an item stored in the cache.

Jump to

Keyboard shortcuts

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