store

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package store contains the sql backed store. It persists objects to a sqlite database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	db.Client
	// contains filtered or unexported fields
}

Store is a SQLite-backed cache.Store

func NewStore

func NewStore(ctx context.Context, example any, keyFunc cache.KeyFunc, c db.Client, shouldEncrypt bool, gvk schema.GroupVersionKind, name string, externalUpdateInfo *sqltypes.ExternalGVKUpdates, selfUpdateInfo *sqltypes.ExternalGVKUpdates) (*Store, error)

NewStore creates a SQLite-backed cache.Store for objects of the given example type

func (*Store) Add

func (s *Store) Add(obj any) error

Add saves an obj, or updates it if it exists in this Store

func (*Store) Delete

func (s *Store) Delete(obj any) error

Delete deletes the given object, if it exists in this Store

func (*Store) DropAll added in v0.6.40

func (s *Store) DropAll(ctx context.Context) error

DropAll effectively removes the store from the database. The store must be recreated with NewStore.

The store shouldn't be used once DropAll is called.

func (*Store) Get

func (s *Store) Get(obj any) (item any, exists bool, err error)

Get returns the object with the same key as obj

func (*Store) GetByKey

func (s *Store) GetByKey(key string) (item any, exists bool, err error)

GetByKey returns the object associated with the given object's key

func (*Store) GetName

func (s *Store) GetName() string

func (*Store) GetShouldEncrypt

func (s *Store) GetShouldEncrypt() bool

func (*Store) GetType

func (s *Store) GetType() reflect.Type

func (*Store) List

func (s *Store) List() []any

List returns a list of all the currently known objects Note: I/O errors will panic this function, as the interface signature does not allow returning errors

func (*Store) ListKeys

func (s *Store) ListKeys() []string

ListKeys returns a list of all the keys currently in this Store Note: Atm it doesn't appear returning nil in the case of an error has any detrimental effects. An error is not uncommon enough nor does it appear to necessitate a panic.

func (*Store) RegisterAfterAdd added in v0.6.7

func (s *Store) RegisterAfterAdd(f func(key string, obj any, txC db.TxClient) error)

RegisterAfterAdd registers a func to be called after each add event

func (*Store) RegisterAfterDelete

func (s *Store) RegisterAfterDelete(f func(key string, obj any, txC db.TxClient) error)

RegisterAfterDelete registers a func to be called after each deletion

func (*Store) RegisterAfterDeleteAll added in v0.6.7

func (s *Store) RegisterAfterDeleteAll(f func(txC db.TxClient) error)

RegisterAfterDelete registers a func to be called after each deletion

func (*Store) RegisterAfterUpdate added in v0.6.7

func (s *Store) RegisterAfterUpdate(f func(key string, obj any, txC db.TxClient) error)

RegisterAfterUpdate registers a func to be called after each update event

func (*Store) RegisterBeforeDropAll added in v0.6.40

func (s *Store) RegisterBeforeDropAll(f func(txC db.TxClient) error)

func (*Store) Replace

func (s *Store) Replace(objects []any, _ string) error

Replace will delete the contents of the Store, using instead the given list

func (*Store) Resync

func (s *Store) Resync() error

Resync is a no-op and is deprecated

func (*Store) Update

func (s *Store) Update(obj any) error

Update saves an obj, or updates it if it exists in this Store

Jump to

Keyboard shortcuts

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