Versions in this module Expand all Collapse all v12 v12.0.0 Aug 20, 2026 Changes in this version + var ErrLoaderTypeMismatch = errors.New("loader type does not match cache type") + var ErrUnknownEvictionPolicy = errors.New("unknown eviction policy") + type Cache struct + func NewInMemoryCache[T any](defaultExpiry time.Duration, opts ...Option) (*Cache[T], error) + func (i *Cache[T]) Close() error + func (i *Cache[T]) Delete(ctx context.Context, key string) error + func (i *Cache[T]) DeleteByPrefix(ctx context.Context, prefix string) error + func (i *Cache[T]) DeleteMany(ctx context.Context, keys []string) error + func (i *Cache[T]) Flush(ctx context.Context) error + func (i *Cache[T]) Get(ctx context.Context, key string) (*T, error) + func (i *Cache[T]) GetMany(ctx context.Context, keys []string) (map[string]*T, error) + func (i *Cache[T]) Ping(ctx context.Context) error + func (i *Cache[T]) Set(ctx context.Context, key string, value *T, opts ...cache.WriteOption) error + func (i *Cache[T]) SetIfPresent(ctx context.Context, key string, value *T, opts ...cache.WriteOption) error + func (i *Cache[T]) SetMany(ctx context.Context, items map[string]*T, opts ...cache.WriteOption) error + type EvictionPolicy uint8 + const EvictLeastRecentlyUsed + const EvictOldestWritten + func ParseEvictionPolicy(name string) (EvictionPolicy, error) + func (p EvictionPolicy) String() string + type Loader func(ctx context.Context, key string) (*T, error) + type Option func(*options) + func WithJanitor(ctx context.Context, interval time.Duration) Option + func WithLoader[T any](loader Loader[T]) Option + func WithLogger(logger logging.Logger) Option + func WithMaxEntries(maxEntries int, policy EvictionPolicy) Option + func WithMetricsProvider(metricsProvider metrics.Provider) Option + func WithTracerProvider(tracerProvider tracing.Provider) Option Other modules containing this package github.com/primandproper/platform-go github.com/primandproper/platform-go/v10 github.com/primandproper/platform-go/v11 github.com/primandproper/platform-go/v2 github.com/primandproper/platform-go/v3 github.com/primandproper/platform-go/v4 github.com/primandproper/platform-go/v5 github.com/primandproper/platform-go/v6 github.com/primandproper/platform-go/v7 github.com/primandproper/platform-go/v8 github.com/primandproper/platform-go/v9