Documentation ¶
Overview ¶
Package db provides functionalities related to data storage. This includes caching as well as persistence storage.
Index ¶
- func CacheDelete(db BucketName, key string) error
- func CacheGet(db BucketName, key string) ([]byte, error)
- func CacheGetRenewExpire(db BucketName, key string, expiration time.Duration) ([]byte, error)
- func CacheSet(db BucketName, key string, value interface{}) error
- func CacheSetWithExpire(db BucketName, key string, value interface{}, expiration time.Duration) error
- func CacheTruncate(db BucketName) error
- func CacheTruncateSoon(db BucketName) error
- func CacheWipeAll() error
- func Delete(db BucketName, key string) error
- func Get(db BucketName, key string) ([]byte, error)
- func GetRenewExpire(db BucketName, key string, expiration time.Duration) ([]byte, error)
- func InitAsBadgerDB()
- func LoadConfig(data []byte)
- func NewNotFoundError(msg string) error
- func Set(db BucketName, key string, value interface{}) error
- func SetWithExpire(db BucketName, key string, value interface{}, expiration time.Duration) error
- func Transact(transaction func(*badger.Txn) error) error
- func TransactRead(txn *badger.Txn, db BucketName, key string, v *[]byte) error
- func TransactWrite(txn *badger.Txn, db BucketName, key string, value interface{}, ...) error
- func View(transaction func(*badger.Txn) error) error
- type BucketName
- type KeyValueDB
- type NotFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDelete ¶
func CacheDelete(db BucketName, key string) error
CacheDelete deletes a given key from the given cache bucket returning a error indicating the success.
func CacheGet ¶
func CacheGet(db BucketName, key string) ([]byte, error)
CacheGet returns the value for a given key from the given cache bucket and a error indicating the success.
func CacheGetRenewExpire ¶
CacheGetRenewExpire returns the value for a given key from the given cache bucket and a error indicating the success. It also sets the time to life for the given key to the given expiration time after which the value cannot be retrieved anymore.
func CacheSet ¶
func CacheSet(db BucketName, key string, value interface{}) error
CacheSet sets the value for a given key in the given cache bucket returning a error indicating the success.
func CacheSetWithExpire ¶
func CacheSetWithExpire(db BucketName, key string, value interface{}, expiration time.Duration) error
CacheSetWithExpire sets the value for a given key in the given cache bucket returning a error indicating the success. The Value will expire after the given time after which it cannot be retrieved anymore.
func CacheTruncate ¶
func CacheTruncate(db BucketName) error
CacheTruncate truncates given cache bucket returning a error indicating the success. After truncating the cache bucket will not hold any keys.
func CacheTruncateSoon ¶
func CacheTruncateSoon(db BucketName) error
CacheTruncateSoon truncates given cache bucket returning a error indicating the success. After truncating the cache bucket will not hold any keys. CacheTruncateSoon does not truncate immediately and only once in a given time span
func CacheWipeAll ¶
func CacheWipeAll() error
CacheWipeAll wipes all data from the cache returning a error indicating the success.
func Delete ¶
func Delete(db BucketName, key string) error
Delete deletes a given key from the given persistent bucket returning a error indicating the success.
func Get ¶
func Get(db BucketName, key string) ([]byte, error)
Get returns the value for a given key from the given persistent bucket and a error indicating the success.
func GetRenewExpire ¶
GetRenewExpire returns the value for a given key from the given persistent bucket and a error indicating the success. It also sets the time to life for the given key to the given expiration time after which the value cannot be retrieved anymore.
func InitAsBadgerDB ¶
func InitAsBadgerDB()
InitAsBadgerDB initializes the cache and persistence KeyValueDB variables with BadgerDBs.
func LoadConfig ¶
func LoadConfig(data []byte)
LoadConfig loads the database config from the given config data
func NewNotFoundError ¶
NewNotFoundError creates a new NotFoundError with the given message.
func Set ¶
func Set(db BucketName, key string, value interface{}) error
Set sets the value for a given key in the given persistent bucket returning a error indicating the success.
func SetWithExpire ¶
func SetWithExpire(db BucketName, key string, value interface{}, expiration time.Duration) error
SetWithExpire sets the value for a given key in the given persistent bucket returning a error indicating the success. The Value will expire after the given time after which it cannot be retrieved anymore.
func TransactRead ¶
TransactRead applies read changes in a transaction
func TransactWrite ¶
func TransactWrite(txn *badger.Txn, db BucketName, key string, value interface{}, expiration time.Duration) error
TransactWrite applies write changes in a transaction
Types ¶
type BucketName ¶
type BucketName int
BucketName is an type aliases used to differentiate different tables / buckets
const ( CACHEStates BucketName = iota CACHEClientConfigs CACHEFlowInfo CACHEDynamicFeatures CACHEDevicePollingResults CACHEHelpPages CACHEHContents CACHEMailActivation )
BucketNames for the cache
const ( DBCommunityFeatures DBPersonalCompareViewSpecs DBNotifications DBNotificationFields DBNotificationProviders DBNotificationFeatures )
BucketNames for persistence storage
type KeyValueDB ¶
type KeyValueDB interface { Get(db BucketName, key string) ([]byte, error) GetRenewExpire(db BucketName, key string, expiration time.Duration) ([]byte, error) Set(db BucketName, key string, value interface{}) error SetWithExpire(db BucketName, key string, value interface{}, expiration time.Duration) error Delete(db BucketName, key string) error Truncate(db BucketName) error TruncateSoon(db BucketName) error Transact(func(*badger.Txn) error) error View(func(txn *badger.Txn) error) error Read(txn *badger.Txn, db BucketName, key string, v *[]byte) error Write(txn *badger.Txn, db BucketName, key string, value interface{}, expiration time.Duration) (err error) }
KeyValueDB is an interface for a Key Value storage
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError is an error type used when a key is not found.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string