local

package
v0.5.110 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotRunning    = DBError("DB is not running")
	ErrWrongPassword = DBError("wrong username or password")

	PermanentTTL = math.MaxInt64
)
View Source
const (
	FixedKey      = "fixed"
	FixedRangeKey = "fixed"
	NoneRangeKey  = "none"
	Delimeter     = "/"
)

Variables

View Source
var DefaultIteratorOptions = badger.DefaultIteratorOptions

Functions

func IsNotFoundError added in v0.5.63

func IsNotFoundError(err error) bool

func NewKey added in v0.5.63

func NewKey(s string) ds.Key

func ToDatatoreErrNotFound added in v0.5.84

func ToDatatoreErrNotFound(err error) error

Types

type Batch added in v0.5.63

type Batch = ds.Batch

type Batching added in v0.5.63

type Batching = ds.Batching

type DB

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

func New

func New(
	dbPath string,
	o *Options,
) (*DB, error)

func (*DB) Close

func (db *DB) Close()

func (*DB) Delete

func (db *DB) Delete(key DatabaseKey) error

func (*DB) GC

func (db *DB) GC()

func (*DB) Get

func (db *DB) Get(key DatabaseKey) ([]byte, error)

func (*DB) GetExpiration

func (db *DB) GetExpiration(key DatabaseKey) (uint64, error)

func (*DB) GetSize

func (db *DB) GetSize(key DatabaseKey) (int64, error)

func (*DB) InnerDB

func (db *DB) InnerDB() *badger.DB

func (*DB) IsClosed

func (db *DB) IsClosed() bool

func (*DB) IsFirstRun

func (db *DB) IsFirstRun() bool

func (*DB) NewTxn

func (db *DB) NewTxn() (WarpTransactioner, error)

func (*DB) NextSequence

func (db *DB) NextSequence() (uint64, error)

func (*DB) Path

func (db *DB) Path() string

func (*DB) Run

func (db *DB) Run(username, password string) (err error)

func (*DB) Set

func (db *DB) Set(key DatabaseKey, value []byte) error

func (*DB) SetWithTTL

func (db *DB) SetWithTTL(key DatabaseKey, value []byte, ttl time.Duration) error

func (*DB) Stats

func (db *DB) Stats() map[string]string

func (*DB) Sync

func (db *DB) Sync() error

type DBError

type DBError string

func (DBError) Error

func (e DBError) Error() string

type DatabaseKey

type DatabaseKey string

func (DatabaseKey) Bytes

func (k DatabaseKey) Bytes() []byte

func (DatabaseKey) DropId

func (k DatabaseKey) DropId() string

func (DatabaseKey) IsEmpty

func (k DatabaseKey) IsEmpty() bool

func (DatabaseKey) String

func (k DatabaseKey) String() string

type DsEntry added in v0.5.63

type DsEntry = dsq.Entry

type Entry added in v0.5.63

type Entry = badger.Entry

type Filter added in v0.5.63

type Filter = dsq.Filter

type IdLayer

type IdLayer string

func (IdLayer) AddId

func (l IdLayer) AddId(mandatoryPrefix string) IdLayer

func (IdLayer) AddReversedTimestamp

func (l IdLayer) AddReversedTimestamp(tm time.Time) RangeLayer

func (IdLayer) Build

func (l IdLayer) Build() DatabaseKey

type Item added in v0.5.63

type Item = badger.Item

type IterKeysFunc

type IterKeysFunc func(key string) error

type Key added in v0.5.63

type Key = ds.Key

type ListItem

type ListItem struct {
	Key   string
	Value []byte
}

type Namespace

type Namespace string

func NewPrefixBuilder

func NewPrefixBuilder(mandatoryNamespace string) Namespace

NewPrefixBuilder creates a new PrefixBuilder instance

func (Namespace) AddRootID

func (ns Namespace) AddRootID(mandatoryPrefix string) ParentLayer

func (Namespace) AddSubPrefix

func (ns Namespace) AddSubPrefix(p string) Namespace

func (Namespace) Build

func (ns Namespace) Build() DatabaseKey

type Options added in v0.5.63

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

func DefaultOptions added in v0.5.63

func DefaultOptions() *Options

func (*Options) WithDiscardRatioGC added in v0.5.63

func (opt *Options) WithDiscardRatioGC(ratio float64) *Options

func (*Options) WithInMemory added in v0.5.63

func (opt *Options) WithInMemory(v bool) *Options

func (*Options) WithIntervalGC added in v0.5.63

func (opt *Options) WithIntervalGC(interval time.Duration) *Options

func (*Options) WithSleepGC added in v0.5.63

func (opt *Options) WithSleepGC(sleep time.Duration) *Options

type OrderByKey added in v0.5.63

type OrderByKey = dsq.OrderByKey

type OrderByKeyDescending added in v0.5.63

type OrderByKeyDescending = dsq.OrderByKeyDescending

type ParentLayer

type ParentLayer string

func (ParentLayer) AddParentId

func (l ParentLayer) AddParentId(mandatoryPrefix string) IdLayer

func (ParentLayer) AddRange

func (l ParentLayer) AddRange(mandatoryPrefix RangePrefix) RangeLayer

func (ParentLayer) AddReversedTimestamp

func (l ParentLayer) AddReversedTimestamp(tm time.Time) RangeLayer

func (ParentLayer) Build

func (l ParentLayer) Build() DatabaseKey

type PrefixBuilder

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

PrefixBuilder is a struct that holds a key and any potential error

func (*PrefixBuilder) AddReaderId

func (pb *PrefixBuilder) AddReaderId(readerId string) *PrefixBuilder

func (*PrefixBuilder) AddWriterId

func (pb *PrefixBuilder) AddWriterId(writerId string) *PrefixBuilder

AddFollowedId adds a following ID segment to the key (reuses user ID validation)

type Query added in v0.5.63

type Query = dsq.Query

type RangeLayer

type RangeLayer string

func (RangeLayer) AddParentId

func (l RangeLayer) AddParentId(mandatoryPrefix string) IdLayer

func (RangeLayer) Build

func (l RangeLayer) Build() DatabaseKey

type RangePrefix

type RangePrefix string

type Result added in v0.5.63

type Result = dsq.Result

type Results added in v0.5.63

type Results = dsq.Results

func NaiveQueryApply added in v0.5.63

func NaiveQueryApply(q Query, qr Results) Results

func ResultsReplaceQuery added in v0.5.63

func ResultsReplaceQuery(r Results, q Query) Results

func ResultsWithContext added in v0.5.63

func ResultsWithContext(q Query, proc func(context.Context, chan<- Result)) Results

type Txn

type Txn = badger.Txn

type WarpDB

type WarpDB = badger.DB

type WarpDBLogger

type WarpDBLogger interface {
	Errorf(string, ...interface{})
	Warningf(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
}

type WarpTransactioner

type WarpTransactioner interface {
	Set(key DatabaseKey, value []byte) error
	Get(key DatabaseKey) ([]byte, error)
	SetWithTTL(key DatabaseKey, value []byte, ttl time.Duration) error
	BatchSet(data []ListItem) (err error)
	Delete(key DatabaseKey) error
	Increment(key DatabaseKey) (uint64, error)
	Decrement(key DatabaseKey) (uint64, error)
	Commit() error
	Discard() error
	Rollback()
	IterateKeys(prefix DatabaseKey, handler IterKeysFunc) error
	ReverseIterateKeys(prefix DatabaseKey, handler IterKeysFunc) error
	List(prefix DatabaseKey, limit *uint64, cursor *string) ([]ListItem, string, error)
	ListKeys(prefix DatabaseKey, limit *uint64, cursor *string) ([]string, string, error)
	BatchGet(keys ...DatabaseKey) ([]ListItem, error)
}

type WriteBatch added in v0.5.63

type WriteBatch = badger.WriteBatch

Jump to

Keyboard shortcuts

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