sqlite

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is an implementation of mghash.DB that uses a Sqlite3 file for persistent storage.

func Open

func Open(ctx context.Context, path string, opts ...Option) (*DB, error)

Open opens the given file and returns it as a *DB. The file is created if it doesn't already exist. The database schema is created in the file if needed. Callers should call Close when finished operating on the database.

func (*DB) Add

func (db *DB) Add(ctx context.Context, h []byte) error

Add adds a hash to db. If it is already present, its last-access time is updated. If db was opened with the Keep option, entries with old last-access times are evicted.

func (*DB) Close

func (db *DB) Close() error

Close releases the resources of s.

func (*DB) Has

func (db *DB) Has(ctx context.Context, h []byte) (bool, error)

Has tells whether db contains the given hash. If found, it also updates the last-access time of the hash.

type Option

type Option func(*DB)

Option is the type of a config option that can be passed to Open.

func Keep

func Keep(d time.Duration) Option

Keep is an Option that sets the amount of time to keep a database entry. By default, DB keeps all entries. Using Keep(d) allows DB to evict entries whose last-access time is older than d.

Jump to

Keyboard shortcuts

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