rcache

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 8 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[K comparable, T any] struct {
	RedisTimeout   time.Duration
	RefreshTimeout time.Duration
	Recheck        time.Duration
	Expires        time.Duration
	// contains filtered or unexported fields
}

func NewCache

func NewCache[K comparable, T any](refreshFn func(context.Context, K) (T, error), keyPrefix string, redisClient *redis.Client) *Cache[K, T]

func (*Cache[K, T]) Check

func (rc *Cache[K, T]) Check(ctx context.Context, key K) (T, bool)

func (*Cache[K, T]) Get

func (rc *Cache[K, T]) Get(ctx context.Context, key K) (T, bool)

func (*Cache[K, T]) GetRecheckKeys

func (rc *Cache[K, T]) GetRecheckKeys(ctx context.Context) []K

func (*Cache[K, T]) Refresh

func (rc *Cache[K, T]) Refresh(ctx context.Context, key K) (T, error)

func (*Cache[K, T]) SetTTL

func (rc *Cache[K, T]) SetTTL(ctx context.Context, key K, value T, ttl1 time.Duration, ttl2 time.Duration) error

func (*Cache[K, T]) Start

func (rc *Cache[K, T]) Start(t time.Duration)

type Item

type Item[T any] struct {
	Value     T
	ExpiresAt time.Time
	RecheckAt time.Time
}

Jump to

Keyboard shortcuts

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