clientcache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 2 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 provides a type-safe client cache with singleflight to prevent duplicate creation

func NewCache

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

NewCache creates a new type-safe client cache

func (*Cache[T]) Clear

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

Clear removes all clients from the cache

func (*Cache[T]) Delete

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

Delete removes a client from the cache

func (*Cache[T]) GetOrCreate

func (c *Cache[T]) GetOrCreate(key string, factory func() (T, error)) (T, error)

GetOrCreate retrieves a cached client or creates a new one using the provided factory function The factory is only called once per key, even under concurrent load

Jump to

Keyboard shortcuts

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