store

package
v0.0.0-...-b5fa7f3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilDB = errors.New("Use of uninitialized DB")
	ErrStale = errors.New("Stale")
)

Functions

func CacheMtime

func CacheMtime[T any](db *DB, mtime time.Time, k string, ver int, new func() (T, error)) (T, error)

func CacheStat

func CacheStat[T any](db *DB, f interface{ Stat() (fs.FileInfo, error) }, k string, ver int, new func() (T, error)) (T, error)

func CacheTTL

func CacheTTL[T any](db *DB, ttl time.Duration, k string, ver int, new func() (T, error)) (T, error)

func Get

func Get[T any](db *DB, k string) (T, error)

func Put

func Put[T any](db *DB, k string, v T) error

Types

type CacheEntry

type CacheEntry[T any] struct {
	Ts  time.Time
	Ver int
	V   T
}

func (CacheEntry[T]) CheckMtime

func (ent CacheEntry[T]) CheckMtime(mtime time.Time, ver int) bool

func (CacheEntry[T]) CheckTTL

func (ent CacheEntry[T]) CheckTTL(ttl time.Duration, ver int) bool

type DB

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

func OpenDB

func OpenDB(dir string, o Options) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Get

func (db *DB) Get(k string, outPtr any) error

func (*DB) Put

func (db *DB) Put(k string, v any) error

type Options

type Options struct {
	Logger pebble.Logger
}

Jump to

Keyboard shortcuts

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