memory

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryConfig

type MemoryConfig struct {
	MaxSize         int           `json:"max_size"`
	DefaultTTL      time.Duration `json:"default_ttl"`
	CleanupInterval time.Duration `json:"cleanup_interval"`
	KeyPrefix       string        `json:"key_prefix"`
	Namespace       string        `json:"namespace"`
}

MemoryConfig holds memory-specific configuration

type MemoryProvider

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

MemoryProvider implements the CacheProvider interface for in-memory caching

func NewMemoryProvider

func NewMemoryProvider(config *MemoryConfig, logger *logrus.Logger) *MemoryProvider

NewMemoryProvider creates a new memory cache provider

func (*MemoryProvider) Connect

func (m *MemoryProvider) Connect(ctx context.Context) error

Connect establishes connection (always succeeds for memory)

func (*MemoryProvider) Delete

func (m *MemoryProvider) Delete(ctx context.Context, key string) error

Delete removes a value from memory

func (*MemoryProvider) DeleteMultiple

func (m *MemoryProvider) DeleteMultiple(ctx context.Context, keys []string) error

DeleteMultiple removes multiple values from memory

func (*MemoryProvider) Disconnect

func (m *MemoryProvider) Disconnect(ctx context.Context) error

Disconnect closes the connection

func (*MemoryProvider) Exists

func (m *MemoryProvider) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in memory

func (*MemoryProvider) Flush

func (m *MemoryProvider) Flush(ctx context.Context) error

Flush clears all cache data

func (*MemoryProvider) Get

func (m *MemoryProvider) Get(ctx context.Context, key string, dest interface{}) error

Get retrieves a value from memory

func (*MemoryProvider) GetConnectionInfo

func (m *MemoryProvider) GetConnectionInfo() *types.ConnectionInfo

GetConnectionInfo returns connection information

func (*MemoryProvider) GetKeys

func (m *MemoryProvider) GetKeys(ctx context.Context, pattern string) ([]string, error)

GetKeys returns keys matching a pattern

func (*MemoryProvider) GetMultiple

func (m *MemoryProvider) GetMultiple(ctx context.Context, keys []string) (map[string]interface{}, error)

GetMultiple retrieves multiple values from memory

func (*MemoryProvider) GetName

func (m *MemoryProvider) GetName() string

GetName returns the provider name

func (*MemoryProvider) GetStats

func (m *MemoryProvider) GetStats(ctx context.Context) (*types.CacheStats, error)

GetStats returns memory cache statistics

func (*MemoryProvider) GetSupportedFeatures

func (m *MemoryProvider) GetSupportedFeatures() []types.CacheFeature

GetSupportedFeatures returns the features supported by memory cache

func (*MemoryProvider) GetTTL

func (m *MemoryProvider) GetTTL(ctx context.Context, key string) (time.Duration, error)

GetTTL returns the TTL of a key

func (*MemoryProvider) InvalidateByTag

func (m *MemoryProvider) InvalidateByTag(ctx context.Context, tag string) error

InvalidateByTag invalidates all keys with a specific tag

func (*MemoryProvider) IsConnected

func (m *MemoryProvider) IsConnected() bool

IsConnected returns the connection status

func (*MemoryProvider) Ping

func (m *MemoryProvider) Ping(ctx context.Context) error

Ping tests the connection (always succeeds for memory)

func (*MemoryProvider) Set

func (m *MemoryProvider) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

Set stores a value in memory

func (*MemoryProvider) SetMultiple

func (m *MemoryProvider) SetMultiple(ctx context.Context, items map[string]interface{}, ttl time.Duration) error

SetMultiple stores multiple values in memory

func (*MemoryProvider) SetTTL

func (m *MemoryProvider) SetTTL(ctx context.Context, key string, ttl time.Duration) error

SetTTL sets the TTL of a key

func (*MemoryProvider) SetWithTags

func (m *MemoryProvider) SetWithTags(ctx context.Context, key string, value interface{}, ttl time.Duration, tags []string) error

SetWithTags stores a value with tags for easier invalidation

Jump to

Keyboard shortcuts

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