cache

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxTTL     = 24 * time.Hour
	DefaultTTL = 1 * time.Hour
)

Variables

This section is empty.

Functions

func NewCacheManager

func NewCacheManager(ctx context.Context, config types.ConfigManager, logger types.Logger, metrics types.MetricsManager, health types.HealthManager) (types.CacheManager, error)

func NewMemoryCache

func NewMemoryCache(ctx context.Context, logger types.Logger, config *types.CacheConfig, health types.HealthManager) (types.CacheManager, error)

func NewRedisCache

func NewRedisCache(ctx context.Context, logger types.Logger, config *types.CacheConfig, health types.HealthManager) (types.CacheManager, error)

func RegisterCacheManager

func RegisterCacheManager(cacheManagerName string, creator types.CacheManagerCreator)

Types

type KeyBuilder

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

type MemoryCache

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

func (*MemoryCache) BuildCacheKey

func (m *MemoryCache) BuildCacheKey(requestPath []byte, dependencies []string, metadata map[string][]byte) string

func (*MemoryCache) Delete

func (m *MemoryCache) Delete(key string) error

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) (interface{}, bool)

func (*MemoryCache) GetRevision

func (m *MemoryCache) GetRevision(key string) uint64

func (*MemoryCache) Invalidate

func (m *MemoryCache) Invalidate(keys ...string) error

func (*MemoryCache) IsRunning

func (m *MemoryCache) IsRunning() bool

func (*MemoryCache) Set

func (m *MemoryCache) Set(key string, value interface{}, ttl time.Duration) error

func (*MemoryCache) SetRevision

func (m *MemoryCache) SetRevision(key string, revision uint64)

func (*MemoryCache) Start

func (m *MemoryCache) Start() error

func (*MemoryCache) Stop

func (m *MemoryCache) Stop() error

type MemoryConfig

type MemoryConfig struct {
	MaxEntries      int    `json:"max_entries"`
	CleanupInterval string `json:"cleanup_interval"`
	MaxMemory       uint64 `json:"max_memory"`
	EvictionPolicy  string `json:"eviction_policy"`
}

type MemoryState

type MemoryState int32
const (
	MemoryStateStopped MemoryState = iota
	MemoryStateStarting
	MemoryStateRunning
	MemoryStateStopping
)

type RedisCache

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

func (*RedisCache) BuildCacheKey

func (r *RedisCache) BuildCacheKey(requestPath []byte, dependencies []string, metadata map[string][]byte) string

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (interface{}, bool)

func (*RedisCache) GetRevision

func (r *RedisCache) GetRevision(key string) uint64

func (*RedisCache) Invalidate

func (r *RedisCache) Invalidate(keys ...string) error

func (*RedisCache) IsRunning

func (r *RedisCache) IsRunning() bool

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}, ttl time.Duration) error

func (*RedisCache) SetRevision

func (r *RedisCache) SetRevision(key string, revision uint64)

func (*RedisCache) Start

func (r *RedisCache) Start() error

func (*RedisCache) Stop

func (r *RedisCache) Stop() error

type RedisConfig

type RedisConfig struct {
	Host                string        `json:"host"`
	Port                int           `json:"port"`
	Password            string        `json:"password"`
	DB                  int           `json:"db"`
	PoolSize            int           `json:"pool_size"`
	MinIdleConnections  int           `json:"min_idle_connections"`
	DialTimeout         time.Duration `json:"dial_timeout"`
	ReadTimeout         time.Duration `json:"read_timeout"`
	WriteTimeout        time.Duration `json:"write_timeout"`
	KeyPrefix           string        `json:"key_prefix"`
	MaxDependencies     int           `json:"max_dependencies"`
	MaxDependentsPerKey int           `json:"max_dependents_per_key"`
}

type RedisState

type RedisState int32
const (
	RedisStateStopped RedisState = iota
	RedisStateStarting
	RedisStateRunning
	RedisStateStopping
)

type State

type State int32
const (
	StateStopped State = iota
	StateStarting
	StateRunning
	StateStopping
)

Jump to

Keyboard shortcuts

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