Documentation
¶
Index ¶
- Variables
- type DB
- func (db *DB) DeleteNarInfoRecord(tx *sql.Tx, hash string) error
- func (db *DB) DeleteNarRecord(tx *sql.Tx, hash string) error
- func (db *DB) GetLeastAccessedNarRecords(tx *sql.Tx, totalFileSize uint64) ([]NarModel, error)
- func (db *DB) GetNarInfoRecord(tx *sql.Tx, hash string) (NarInfoModel, error)
- func (db *DB) GetNarInfoRecordByID(tx *sql.Tx, id int64) (NarInfoModel, error)
- func (db *DB) GetNarRecord(tx *sql.Tx, hash string) (NarModel, error)
- func (db *DB) InsertNarInfoRecord(tx *sql.Tx, hash string) (sql.Result, error)
- func (db *DB) InsertNarRecord(tx *sql.Tx, narInfoID int64, hash, compression string, fileSize uint64) (sql.Result, error)
- func (db *DB) NarTotalSize(tx *sql.Tx) (uint64, error)
- func (db *DB) TouchNarInfoRecord(tx *sql.Tx, hash string) (sql.Result, error)
- func (db *DB) TouchNarRecord(tx *sql.Tx, hash string) (sql.Result, error)
- type NarInfoModel
- type NarModel
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned if record is not found in the database. ErrNotFound = errors.New("not found") // ErrAlreadyExists is returned if record insertion failed due to uniqueness constraint. ErrAlreadyExists = errors.New("error already exists") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB is the main database wrapping *sql.DB and have functions that can operate on nar and narinfos.
func (*DB) DeleteNarInfoRecord ¶ added in v0.0.10
DeleteNarInfoRecord deletes the narinfo record.
func (*DB) DeleteNarRecord ¶ added in v0.0.10
DeleteNarInfoRecord deletes the narinfo record.
func (*DB) GetLeastAccessedNarRecords ¶ added in v0.0.11
GetLeastAccessedNarRecords returns all records with the oldest last_accessed_at up to totalFileSize left behind.
func (*DB) GetNarInfoRecord ¶ added in v0.0.6
GetNarInfoRecord returns a narinfo record given its hash. If no nar was found with the given hash then ErrNotFound is returned instead.
func (*DB) GetNarInfoRecordByID ¶ added in v0.0.11
GetNarInfoRecordByID returns a narinfo record given its hash. If no nar was found with the given hash then ErrNotFound is returned instead.
func (*DB) GetNarRecord ¶ added in v0.0.6
GetNarRecord returns a nar record given its hash. If no nar was found with the given hash then ErrNotFound is returned instead.
func (*DB) InsertNarInfoRecord ¶
InsertNarInfoRecord creates a new narinfo record in the database.
func (*DB) InsertNarRecord ¶
func (db *DB) InsertNarRecord(tx *sql.Tx, narInfoID int64, hash, compression string, fileSize uint64, ) (sql.Result, error)
InsertNarRecord creates a new nar record in the database.
func (*DB) NarTotalSize ¶ added in v0.0.11
NarTotalSize returns the sum of FileSize of all nar records.
func (*DB) TouchNarInfoRecord ¶
TouchNarInfoRecord updates the last_accessed_at of a narinfo record in the database.