cachestore

package
v0.0.0-...-a2e0aaf Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0, MIT Imports: 5 Imported by: 4

Documentation

Overview

Automod component for caching arbitrary data (as JSON strings) with a fixed TTL and purging.

Includes an interface and implementations using redis and in-process memory.

This is used by the rules engine to cache things like account metadata, improving latency and reducing load on authoritative backend systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStore

type CacheStore interface {
	Get(ctx context.Context, name, key string) (string, error)
	Set(ctx context.Context, name, key string, val string) error
	Purge(ctx context.Context, name, key string) error
}

type MemCacheStore

type MemCacheStore struct {
	Data *expirable.LRU[string, string]
}

func NewMemCacheStore

func NewMemCacheStore(capacity int, ttl time.Duration) MemCacheStore

func (MemCacheStore) Get

func (s MemCacheStore) Get(ctx context.Context, name, key string) (string, error)

func (MemCacheStore) Purge

func (s MemCacheStore) Purge(ctx context.Context, name, key string) error

func (MemCacheStore) Set

func (s MemCacheStore) Set(ctx context.Context, name, key string, val string) error

type RedisCacheStore

type RedisCacheStore struct {
	Data *cache.Cache
	TTL  time.Duration
}

func NewRedisCacheStore

func NewRedisCacheStore(redisURL string, ttl time.Duration) (*RedisCacheStore, error)

func (RedisCacheStore) Get

func (s RedisCacheStore) Get(ctx context.Context, name, key string) (string, error)

func (RedisCacheStore) Purge

func (s RedisCacheStore) Purge(ctx context.Context, name, key string) error

func (RedisCacheStore) Set

func (s RedisCacheStore) Set(ctx context.Context, name, key string, val string) error

Jump to

Keyboard shortcuts

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