cache

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 0 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[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](costFunc func(T) int64, cacheType string) (*Cache[T], error)

func (*Cache[T]) Clear

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

func (*Cache[T]) Del

func (c *Cache[T]) Del(key string)

func (*Cache[T]) Get

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

func (*Cache[T]) GetItemCount

func (c *Cache[T]) GetItemCount() int64

func (*Cache[T]) SetWithTTL

func (c *Cache[T]) SetWithTTL(key string, value T, cost int64,
	ttl time.Duration) bool

func (*Cache[T]) Stats

func (c *Cache[T]) Stats() map[string]interface{}

func (*Cache[T]) StatsCopy

func (c *Cache[T]) StatsCopy() map[string]interface{}

func (*Cache[T]) Wait

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

Jump to

Keyboard shortcuts

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