multilevel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package multilevel composes an L1 (local) and L2 (remote) cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Cache reads L1 first, falls back to L2, and writes through to both.

func New

func New[K comparable, V any](l1, l2 cache.Cache[K, V]) (*Cache[K, V], error)

New creates a multilevel cache. Both l1 and l2 are required.

func (*Cache[K, V]) Clear

func (c *Cache[K, V]) Clear(ctx context.Context) error

func (*Cache[K, V]) Close

func (c *Cache[K, V]) Close() error

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(ctx context.Context, key K) error

func (*Cache[K, V]) Exists

func (c *Cache[K, V]) Exists(ctx context.Context, key K) (bool, error)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(ctx context.Context, key K) (V, error)

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(ctx context.Context, key K, value V, ttl time.Duration) error

Jump to

Keyboard shortcuts

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