cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT, MIT Imports: 5 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[S comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[S comparable, T any](defaultTTL time.Duration) *Cache[S, T]

func (*Cache[S, T]) Clear

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

func (*Cache[S, T]) Count

func (c *Cache[S, T]) Count() int

func (*Cache[S, T]) Delete

func (c *Cache[S, T]) Delete(key S)

func (*Cache[S, T]) Flush

func (c *Cache[S, T]) Flush()

func (*Cache[S, T]) Get

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

func (*Cache[S, T]) Has

func (c *Cache[S, T]) Has(key S) bool

func (*Cache[S, T]) Put

func (c *Cache[S, T]) Put(key S, value T)

func (*Cache[S, T]) PutWithExpiration

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

func (*Cache[S, T]) PutWithTTL

func (c *Cache[S, T]) PutWithTTL(key S, value T, ttl time.Duration)

func (*Cache[S, T]) Watch

func (c *Cache[S, T]) Watch(ctx context.Context, interval time.Duration)

type LoadingCache

type LoadingCache[S comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewLoadingCache

func NewLoadingCache[S comparable, T any](ctx context.Context, loader function.Loader[S, T], defaultTTL time.Duration) *LoadingCache[S, T]

func (*LoadingCache[S, T]) Get

func (c *LoadingCache[S, T]) Get(key S) (T, bool)

func (*LoadingCache[S, T]) Set

func (c *LoadingCache[S, T]) Set(key S, value T)

func (*LoadingCache[S, T]) SetWithTTL

func (c *LoadingCache[S, T]) SetWithTTL(key S, value T, ttl time.Duration)

Directories

Path Synopsis
example command

Jump to

Keyboard shortcuts

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