cache

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheUnavailable = errors.New("cache unavailable")

ErrCacheUnavailable is returned by NopStore for write operations.

View Source
var ErrOfflineDataMissing = errors.New("offline data not synced; run 'vulners offline sync' first")

ErrOfflineDataMissing is returned when offline data is not cached.

Functions

This section is empty.

Types

type CollectionMeta

type CollectionMeta struct {
	Collection string    `json:"collection"`
	Count      int       `json:"count"`
	SyncedAt   time.Time `json:"syncedAt"`
}

CollectionMeta holds metadata about a synced collection.

type NopStore

type NopStore struct{}

NopStore is a no-op Store returned when the cache database cannot be opened. Read operations return ErrOfflineDataMissing; write operations return ErrCacheUnavailable.

func NewNopStore

func NewNopStore() *NopStore

NewNopStore returns a NopStore.

func (*NopStore) Close

func (*NopStore) Close() error

func (*NopStore) GetBulletin

func (*NopStore) GetBulletin(context.Context, string) (*vulners.Bulletin, error)

func (*NopStore) GetCollectionMeta

func (*NopStore) GetCollectionMeta(context.Context) ([]CollectionMeta, error)

func (*NopStore) GetLastSyncTime

func (*NopStore) GetLastSyncTime(context.Context, string) (time.Time, error)

func (*NopStore) Purge

func (*NopStore) Purge(context.Context) error

func (*NopStore) PutBulletins

func (*NopStore) PutBulletins(context.Context, string, []vulners.Bulletin) error

func (*NopStore) SearchBulletins

func (*NopStore) SearchBulletins(context.Context, string, int, int) ([]vulners.Bulletin, int, error)

type SQLiteStore

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

SQLiteStore implements Store using a SQLite database.

func NewSQLiteStore

func NewSQLiteStore(dbPath string, logger *slog.Logger) (*SQLiteStore, error)

NewSQLiteStore opens or creates a SQLite cache at the given path.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) GetBulletin

func (s *SQLiteStore) GetBulletin(ctx context.Context, id string) (*vulners.Bulletin, error)

func (*SQLiteStore) GetCollectionMeta

func (s *SQLiteStore) GetCollectionMeta(ctx context.Context) ([]CollectionMeta, error)

func (*SQLiteStore) GetLastSyncTime

func (s *SQLiteStore) GetLastSyncTime(ctx context.Context, collection string) (time.Time, error)

func (*SQLiteStore) Purge

func (s *SQLiteStore) Purge(ctx context.Context) error

func (*SQLiteStore) PutBulletins

func (s *SQLiteStore) PutBulletins(ctx context.Context, collection string, bulletins []vulners.Bulletin) error

func (*SQLiteStore) SearchBulletins

func (s *SQLiteStore) SearchBulletins(ctx context.Context, query string, limit, offset int) ([]vulners.Bulletin, int, error)

type Store

type Store interface {
	GetBulletin(ctx context.Context, id string) (*vulners.Bulletin, error)
	PutBulletins(ctx context.Context, collection string, bulletins []vulners.Bulletin) error
	SearchBulletins(ctx context.Context, query string, limit, offset int) ([]vulners.Bulletin, int, error)
	GetCollectionMeta(ctx context.Context) ([]CollectionMeta, error)
	GetLastSyncTime(ctx context.Context, collection string) (time.Time, error)
	Purge(ctx context.Context) error
	Close() error
}

Store is the interface for the local cache.

Jump to

Keyboard shortcuts

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