cache

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 11 Imported by: 2 modules, 1 package

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

Overview

Package cache provides a factory function to create Cache instances.

Index

Constants

View Source
const (
	DefaultDriver = "memory" // Define a default driver
)
View Source
const Module = "storage.cache"

Variables

View Source
var DefaultProvider component.Provider = func(ctx context.Context, h component.Handle) (any, error) {
	cfg, err := comp.AsConfig[cachev1.CacheConfig](h)
	if err != nil {
		return nil, err
	}
	return New(cfg)
}

DefaultProvider is the default provider for cache components.

Functions

func New

New creates a new Cache instance based on the provided configuration. It uses the internal factory registry to find the appropriate provider. To use a specific provider (e.g., "redis"), ensure its package is imported for its side effects (e.g., `import _ "path/to/redis/provider"`), which will register the provider's factory.

func Register added in v0.2.13

func Register(name string, factory Factory)

Register registers a new cache factory with the default factory registry.

func Resolve added in v0.2.19

func Resolve(ctx context.Context, source any, opts *component.LoadOptions) (*component.ModuleConfig, error)

Resolve resolves the cache configuration.

Types

type Factory added in v0.2.13

type Factory interface {
	NewCache(cfg *cachev1.CacheConfig, opts ...options.Option) (storageiface.Cache, error)
}

Factory is the interface for creating new Cache components.

type FactoryFunc added in v0.2.13

type FactoryFunc func(cfg *cachev1.CacheConfig, opts ...options.Option) (storageiface.Cache, error)

FactoryFunc is a function type that implements the Factory interface.

func (FactoryFunc) NewCache added in v0.2.13

func (f FactoryFunc) NewCache(cfg *cachev1.CacheConfig, opts ...options.Option) (storageiface.Cache, error)

NewCache creates a new Cache component based on the provided configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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