Documentation ¶
Overview ¶
Package store contains the sql backed store. It persists objects to a sqlite database.
Index ¶
- type DBClient
- type Store
- func (s *Store) Add(obj any) error
- func (s *Store) Delete(obj any) error
- func (s *Store) Get(obj any) (item any, exists bool, err error)
- func (s *Store) GetByKey(key string) (item any, exists bool, err error)
- func (s *Store) GetName() string
- func (s *Store) GetShouldEncrypt() bool
- func (s *Store) GetType() reflect.Type
- func (s *Store) List() []any
- func (s *Store) ListKeys() []string
- func (s *Store) RegisterAfterDelete(f func(key string, txC db.TXClient) error)
- func (s *Store) RegisterAfterUpsert(f func(key string, obj any, txC db.TXClient) error)
- func (s *Store) Replace(objects []any, _ string) error
- func (s *Store) Resync() error
- func (s *Store) Update(obj any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBClient ¶
type DBClient interface { BeginTx(ctx context.Context, forWriting bool) (db.TXClient, error) Prepare(stmt string) *sql.Stmt QueryForRows(ctx context.Context, stmt transaction.Stmt, params ...any) (*sql.Rows, error) ReadObjects(rows db.Rows, typ reflect.Type, shouldDecrypt bool) ([]any, error) ReadStrings(rows db.Rows) ([]string, error) ReadInt(rows db.Rows) (int, error) Upsert(tx db.TXClient, stmt *sql.Stmt, key string, obj any, shouldEncrypt bool) error CloseStmt(closable db.Closable) error }
type Store ¶
type Store struct { DBClient // contains filtered or unexported fields }
Store is a SQLite-backed cache.Store
func NewStore ¶
func NewStore(example any, keyFunc cache.KeyFunc, c DBClient, shouldEncrypt bool, name string) (*Store, error)
NewStore creates a SQLite-backed cache.Store for objects of the given example type
func (*Store) GetShouldEncrypt ¶
func (*Store) List ¶
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 ¶
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) RegisterAfterDelete ¶
RegisterAfterDelete registers a func to be called after each deletion
func (*Store) RegisterAfterUpsert ¶
RegisterAfterUpsert registers a func to be called after each upsert