inmemory

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultExpiration int32 `yaml:"defaultExpiration" json:"defaultExpiration"`
	CleanupInterval   int32 `yaml:"cleanupInterval" json:"cleanupInterval"`
}

Config is the configuration for the in-memory cache.

type InMemoryCache

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

InMemoryCache holds the handler for the in-memory cache using go-cache.

func NewCache

func NewCache(config *Config) (*InMemoryCache, error)

NewCache creates a new in-memory cache instance.

func (*InMemoryCache) Delete

func (imc *InMemoryCache) Delete(_ context.Context, key string) error

Delete removes the value for the given key.

func (*InMemoryCache) Flush

func (imc *InMemoryCache) Flush(_ context.Context)

Flush removes all items from the cache.

func (*InMemoryCache) Get

func (imc *InMemoryCache) Get(_ context.Context, key string) (any, error)

Get retrieves the value for the given key.

func (*InMemoryCache) GetByPattern

func (imc *InMemoryCache) GetByPattern(ctx context.Context, keyPattern string) (map[string]any, error)

GetByPattern returns all values whose keys match the given glob pattern.

func (*InMemoryCache) ItemCount

func (imc *InMemoryCache) ItemCount() int

ItemCount returns the number of items in the cache.

func (*InMemoryCache) ScanKeys

func (imc *InMemoryCache) ScanKeys(_ context.Context, pattern string) ([]string, error)

ScanKeys returns all keys matching the given glob pattern. Pattern uses * to match any sequence of characters and ? to match any single character.

func (*InMemoryCache) Set

func (imc *InMemoryCache) Set(_ context.Context, key string, value any, ttl time.Duration) error

Set stores a value with the given key and TTL.

Jump to

Keyboard shortcuts

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