decorators

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package decorators provides cache decorators for cross-cutting concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder composes decorators around a base ByteCache.

func NewBuilder

func NewBuilder(base interfaces.ByteCache, name string) *Builder

NewBuilder creates a new decorator builder wrapping the given base cache.

func (*Builder) Build

func (b *Builder) Build() interfaces.ByteCache

Build constructs the decorated cache. Decorators are applied inside-out: base → circuit_breaker → timeout → metrics (metrics is outermost).

func (*Builder) WithCircuitBreaker

func (b *Builder) WithCircuitBreaker(cb interfaces.CircuitBreaker) *Builder

WithCircuitBreaker adds a circuit breaker that gracefully degrades cache operations when the cache backend is unavailable. When the circuit is open, Get returns (nil, false) and Set/Delete become no-ops.

func (*Builder) WithMetrics

func (b *Builder) WithMetrics(m interfaces.Metrics) *Builder

WithMetrics adds a metrics decorator that records hits, misses, and operation durations via the interfaces.Metrics abstraction.

func (*Builder) WithTimeout

func (b *Builder) WithTimeout(d time.Duration) *Builder

WithTimeout adds a per-operation deadline. Operations that exceed the timeout are cancelled via context.

Jump to

Keyboard shortcuts

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