cache

package
v0.0.0-...-61eb987 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 7 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 {
	// SyncInterval represents how frequently the cache will attempt to sync
	// with the internal subscription store to retrieve the latest data. It
	// defaults to 60s.
	SyncInterval time.Duration
}

type Option

type Option func(*Store)

func WithLogger

func WithLogger(l loglib.Logger) Option

type Store

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

Store is a wrapper around a subscription store that keeps an in memory cache to minimise calls to the persistent store. It is concurrency safe. The cache contents will be refreshed on a configurable interval. This is an ephemeral lightweight wrapper that doesn't control memory usage. Should only be used when the amount of subscriptions is manageable for the resources allocated. The sync interval will represent in the worst case scenario the staleness of the cache.

func New

func New(ctx context.Context, store store.Store, cfg *Config, opts ...Option) (*Store, error)

NewStoreCache will wrap the store on input, providing a simple in memory cache to minimise calls to the persistent store. It will perform an initial warm up to retrieve all existing subscriptions, and will sync with the store on input on a configured interval.

func (*Store) CreateSubscription

func (s *Store) CreateSubscription(ctx context.Context, subscription *subscription.Subscription) error

func (*Store) DeleteSubscription

func (s *Store) DeleteSubscription(ctx context.Context, subscription *subscription.Subscription) error

func (*Store) GetSubscriptions

func (s *Store) GetSubscriptions(ctx context.Context, action, schema, table string) ([]*subscription.Subscription, error)

Jump to

Keyboard shortcuts

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