database

package
v0.0.0-...-a6eb964 Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusRemove ...
	StatusRemove = iota
	// StatusActive ...
	StatusActive
)

Variables

View Source
var (
	// LibraryBucket ...
	LibraryBucket = []byte("Library")
	// BitTorrentBucket ...
	BitTorrentBucket = []byte("BitTorrent")
	// HistoryBucket ...
	HistoryBucket = []byte("History")
	// TorrentHistoryBucket ...
	TorrentHistoryBucket = []byte("TorrentHistory")
	// SearchCacheBucket ...
	SearchCacheBucket = []byte("SearchCache")

	// CommonBucket ...
	CommonBucket = []byte("Common")
)

Buckets ...

View Source
var CacheBuckets = [][]byte{
	CommonBucket,
}

CacheBuckets represents buckets in Cache database

Functions

func CreateBoltDB

func CreateBoltDB(conf *config.Configuration, fileName string, backupFileName string) (*bolt.DB, error)

CreateBoltDB ...

func CreateSqliteDB

func CreateSqliteDB(conf *config.Configuration, fileName string, backupFileName string) (*sql.DB, error)

CreateSqliteDB ...

func ParseCacheItem

func ParseCacheItem(item []byte) (int, []byte)

ParseCacheItem ...

func RestoreBackup

func RestoreBackup(databasePath string, backupPath string)

RestoreBackup ...

Types

type BTItem

type BTItem struct {
	ID      int      `json:"id"`
	State   int      `json:"state"`
	Type    string   `json:"type"`
	Files   []string `json:"files"`
	ShowID  int      `json:"showid"`
	Season  int      `json:"season"`
	Episode int      `json:"episode"`
	Query   string   `json:"query"`
}

BTItem ...

type BoltDatabase

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

BoltDatabase ...

func GetBolt

func GetBolt() *BoltDatabase

GetBolt returns common database

func GetCache

func GetCache() *BoltDatabase

GetCache returns Cache database

func InitBoltDB

func InitBoltDB(conf *config.Configuration) (*BoltDatabase, error)

InitBoltDB ...

func InitCacheDB

func InitCacheDB(conf *config.Configuration) (*BoltDatabase, error)

InitCacheDB ...

func NewBoltDB

func NewBoltDB() (*BoltDatabase, error)

NewBoltDB ...

func (*BoltDatabase) AsWriter

func (d *BoltDatabase) AsWriter(bucket []byte, key string) *DBWriter

AsWriter ...

func (*BoltDatabase) BatchDelete

func (d *BoltDatabase) BatchDelete(bucket []byte, keys []string) error

BatchDelete ...

func (*BoltDatabase) BatchSet

func (d *BoltDatabase) BatchSet(bucket []byte, objects map[string]string) error

BatchSet ...

func (*BoltDatabase) BatchSetBytes

func (d *BoltDatabase) BatchSetBytes(bucket []byte, objects map[string][]byte) error

BatchSetBytes ...

func (*BoltDatabase) BatchSetObject

func (d *BoltDatabase) BatchSetObject(bucket []byte, objects map[string]interface{}) error

BatchSetObject ...

func (*BoltDatabase) CacheCleanup

func (d *BoltDatabase) CacheCleanup()

CacheCleanup ...

func (*BoltDatabase) CheckBucket

func (d *BoltDatabase) CheckBucket(bucket []byte) error

CheckBucket ...

func (*BoltDatabase) Close

func (d *BoltDatabase) Close()

Close ...

func (*BoltDatabase) CreateBackup

func (d *BoltDatabase) CreateBackup(backupPath string)

CreateBackup ...

func (*BoltDatabase) Delete

func (d *BoltDatabase) Delete(bucket []byte, key string) error

Delete ...

func (*BoltDatabase) DeleteWithPrefix

func (d *BoltDatabase) DeleteWithPrefix(bucket []byte, prefix []byte)

DeleteWithPrefix ...

func (*BoltDatabase) ForEach

func (d *BoltDatabase) ForEach(bucket []byte, callback callBackWithError) error

ForEach ...

func (*BoltDatabase) Get

func (d *BoltDatabase) Get(bucket []byte, key string) (string, error)

Get ...

func (*BoltDatabase) GetBytes

func (d *BoltDatabase) GetBytes(bucket []byte, key string) (value []byte, err error)

GetBytes ...

func (*BoltDatabase) GetCached

func (d *BoltDatabase) GetCached(bucket []byte, key string) (string, error)

GetCached ...

func (*BoltDatabase) GetCachedBytes

func (d *BoltDatabase) GetCachedBytes(bucket []byte, key string) (cacheValue []byte, err error)

GetCachedBytes ...

func (*BoltDatabase) GetCachedObject

func (d *BoltDatabase) GetCachedObject(bucket []byte, key string, item interface{}) (err error)

GetCachedObject ...

func (*BoltDatabase) GetFilename

func (d *BoltDatabase) GetFilename() string

GetFilename returns bolt filename

func (*BoltDatabase) GetObject

func (d *BoltDatabase) GetObject(bucket []byte, key string, item interface{}) (err error)

GetObject ...

func (*BoltDatabase) Has

func (d *BoltDatabase) Has(bucket []byte, key string) (ret bool)

Has checks for existence of a key

func (*BoltDatabase) MaintenanceRefreshHandler

func (d *BoltDatabase) MaintenanceRefreshHandler()

MaintenanceRefreshHandler ...

func (*BoltDatabase) RecreateBucket

func (d *BoltDatabase) RecreateBucket(bucket []byte) error

RecreateBucket ...

func (*BoltDatabase) Seek

func (d *BoltDatabase) Seek(bucket []byte, prefix string, callback callBack) error

Seek ...

func (*BoltDatabase) Set

func (d *BoltDatabase) Set(bucket []byte, key string, value string) error

Set ...

func (*BoltDatabase) SetBytes

func (d *BoltDatabase) SetBytes(bucket []byte, key string, value []byte) error

SetBytes ...

func (*BoltDatabase) SetCached

func (d *BoltDatabase) SetCached(bucket []byte, seconds int, key string, value string) error

SetCached ...

func (*BoltDatabase) SetCachedBytes

func (d *BoltDatabase) SetCachedBytes(bucket []byte, seconds int, key string, value []byte) error

SetCachedBytes ...

func (*BoltDatabase) SetCachedObject

func (d *BoltDatabase) SetCachedObject(bucket []byte, seconds int, key string, item interface{}) error

SetCachedObject ...

func (*BoltDatabase) SetObject

func (d *BoltDatabase) SetObject(bucket []byte, key string, item interface{}) error

SetObject ...

type DBWriter

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

DBWriter ...

func (*DBWriter) Write

func (w *DBWriter) Write(b []byte) (n int, err error)

Write ...

type SqliteDatabase

type SqliteDatabase struct {
	*sql.DB
	// contains filtered or unexported fields
}

SqliteDatabase ...

func Get

func Get() *SqliteDatabase

Get returns sqlite database

func InitSqliteDB

func InitSqliteDB(conf *config.Configuration) (*SqliteDatabase, error)

InitSqliteDB ...

func (*SqliteDatabase) AddSearchHistory

func (d *SqliteDatabase) AddSearchHistory(historyType, query string)

AddSearchHistory adds query to search history, according to media type

func (*SqliteDatabase) AddTorrentHistory

func (d *SqliteDatabase) AddTorrentHistory(infoHash, name string, b []byte)

AddTorrentHistory saves last used torrent

func (d *SqliteDatabase) AddTorrentLink(tmdbID, infoHash string, b []byte)

AddTorrentLink saves link between torrent file and tmdbID entry

func (*SqliteDatabase) Close

func (d *SqliteDatabase) Close()

Close ...

func (*SqliteDatabase) CreateBackup

func (d *SqliteDatabase) CreateBackup(backupPath string)

CreateBackup ...

func (*SqliteDatabase) DeleteBTItem

func (d *SqliteDatabase) DeleteBTItem(infoHash string) error

DeleteBTItem ...

func (*SqliteDatabase) GetBTItem

func (d *SqliteDatabase) GetBTItem(infoHash string) *BTItem

GetBTItem ...

func (*SqliteDatabase) GetCount

func (d *SqliteDatabase) GetCount(sql string) (count int)

GetCount is a helper for returning single column int result

func (*SqliteDatabase) GetFilename

func (d *SqliteDatabase) GetFilename() string

GetFilename returns sqlite filename

func (*SqliteDatabase) GetSetting

func (d *SqliteDatabase) GetSetting(name string) (value string)

GetSetting ...

func (*SqliteDatabase) MaintenanceRefreshHandler

func (d *SqliteDatabase) MaintenanceRefreshHandler()

MaintenanceRefreshHandler ...

func (*SqliteDatabase) SetSetting

func (d *SqliteDatabase) SetSetting(name, value string)

SetSetting ...

func (*SqliteDatabase) UpdateBTItem

func (d *SqliteDatabase) UpdateBTItem(infoHash string, mediaID int, mediaType string, files []string, query string, infos ...int) error

UpdateBTItem ...

func (*SqliteDatabase) UpdateBTItemFiles

func (d *SqliteDatabase) UpdateBTItemFiles(infoHash string, files []string) error

UpdateBTItemFiles ...

func (*SqliteDatabase) UpdateBTItemStatus

func (d *SqliteDatabase) UpdateBTItemStatus(infoHash string, status int) error

UpdateBTItemStatus ...

Jump to

Keyboard shortcuts

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