store

package
v0.6.38 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) 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 transaction.Client) 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 transaction.Client) 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 transaction.Client) 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 transaction.Client) error)

RegisterAfterUpdate registers a func to be called after each update event

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