cache

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSubsystem

func GetSubsystem(ctx context.Context) string

func SetSubsystem

func SetSubsystem(ctx context.Context, subsystem string) context.Context

func WithMaxAge added in v1.33.0

func WithMaxAge(maxAge time.Duration) func(*RefreshOpts)

func WithMode

func WithMode(mode Mode) func(*RefreshOpts)

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

func NewServerCache

func NewServerCache(client *hcloud.Client, defaultMode Mode, defaultMaxAge time.Duration) *Cache[hcloud.Server]

func (*Cache[T]) All added in v1.33.0

func (c *Cache[T]) All(ctx context.Context, opts ...RefreshOption) ([]*T, error)

func (*Cache[T]) ByID

func (c *Cache[T]) ByID(ctx context.Context, id int64, opts ...RefreshOption) (*T, error)

func (*Cache[T]) ByName

func (c *Cache[T]) ByName(ctx context.Context, name string, opts ...RefreshOption) (*T, error)

type Mode

type Mode string
const (
	// ModeAll fetches and caches all entries.
	ModeAll Mode = "all"
	// ModeOne fetches and caches one entry.
	ModeOne Mode = "one"
	// ModeOff disables caching.
	ModeOff Mode = "off"
)

type RefreshOption

type RefreshOption func(ro *RefreshOpts)

type RefreshOpts

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

Jump to

Keyboard shortcuts

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