Documentation ¶
Index ¶
- type KeyValue
- type PGKeyValueStore
- func (c *PGKeyValueStore) Add(ctx context.Context, key string, value []byte) (bool, error)
- func (c *PGKeyValueStore) AddKey(ctx context.Context, key string) (bool, error)
- func (c *PGKeyValueStore) Cleanup(ctx context.Context, lifespan time.Duration) error
- func (c *PGKeyValueStore) Get(ctx context.Context, key string) ([]byte, error)
- func (c *PGKeyValueStore) LoadOrStoreBatch(ctx context.Context, batch []*KeyValue) (map[string][]byte, error)
- func (c *PGKeyValueStore) PeriodicCleanup(ctx context.Context, interval time.Duration, lifespan time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PGKeyValueStore ¶
PGKeyValueStore is a time-limited key-value store backed by postgres with a local LRU cache. The store is write-only, i.e., writing to an existing key will return an error (of type *armadaerrors.ErrAlreadyExists). Keys can only be deleted by running the cleanup function. Deleting keys does not cause caches to update, i.e., nodes may have an inconsistent view if keys are deleted.
func (*PGKeyValueStore) Add ¶
Add adds a key-value pair. Returns true if successful and false if the key already exists. The postgres table backing the key-value storage is created automatically if it doesn't already exist.
func (*PGKeyValueStore) Get ¶
Get returns the value associated with the provided key, or &armadaerrors.ErrNotFound if the key can't be found.
func (*PGKeyValueStore) LoadOrStoreBatch ¶
func (c *PGKeyValueStore) LoadOrStoreBatch(ctx context.Context, batch []*KeyValue) (map[string][]byte, error)
LoadOrStoreBatch returns the existing values for the supplied keys if present. Otherwise, it stores and returns the supplied value. The postgres table backing the key-value storage is created automatically if it doesn't already exist.
func (*PGKeyValueStore) PeriodicCleanup ¶
func (c *PGKeyValueStore) PeriodicCleanup(ctx context.Context, interval time.Duration, lifespan time.Duration) error
PeriodicCleanup starts a goroutine that automatically runs the cleanup job every interval until the provided context is cancelled.