db

package
v0.0.0-...-0206da9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClassNotFound       = errors.New("unable to determine class of db object")
	ErrUnknownType         = errors.New("unable to determine type of the object")
	ErrUnsupportedEncoding = errors.New("unsupported encoding")
)
View Source
var (
	DefaultResultLimit uint = 100
)

Functions

func BytesToObj

func BytesToObj(b []byte) (interface{}, error)

func GetClass

func GetClass(b []byte) (string, error)

Types

type Config

type Config struct {
	BadgerOpts badger.Options `yaml:"badger_opts"`
	Encoding   EncodingType   `yaml:"encoding"`
	Compress   bool           `yaml:"compress"`
}

type DB

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

func New

func New(cfg Config) (db *DB, err error)

func (*DB) Close

func (d *DB) Close() error

func (*DB) Delete

func (d *DB) Delete(k string) error

func (*DB) Exists

func (d *DB) Exists(k string) (bool, error)

func (*DB) Get

func (d *DB) Get(k string, obj interface{}) error

func (*DB) Keys

func (d *DB) Keys(prefix string) (keys []string)

func (*DB) Put

func (d *DB) Put(k string, v any) error

func (*DB) Where

func (d *DB) Where(m Query[any]) ([]any, error)

type DocQuery

type DocQuery struct {
	ItemQuery
	Title       gocache.StringQuery
	Symbols     gocache.StringQuery
	Sectors     gocache.StringQuery
	Source      gocache.StringQuery
	ContentType gocache.StringQuery
	Type        gocache.StringQuery
	PostedDate  gocache.TimeQuery
}

func (DocQuery) GetLimit

func (d DocQuery) GetLimit() uint

func (DocQuery) Match

func (d DocQuery) Match(v gocache.Object) bool

type EncodingType

type EncodingType int
const (
	Msgpack EncodingType = iota
	Json
	Bson
	Binary
)

type ItemQuery

type ItemQuery struct {
	Created  gocache.TimeQuery
	Class    gocache.StringQuery
	Archived gocache.BoolQuery
	Limit    uint
}

func (ItemQuery) GetLimit

func (q ItemQuery) GetLimit() uint

func (ItemQuery) Match

func (i ItemQuery) Match(v gocache.Object) bool

type KeyStore

type KeyStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type Query

type Query[T any] interface {
	Prefix() string
	Unmarshal([]byte, func([]byte, interface{}) error) (T, error)
	Match(T) bool
}

Jump to

Keyboard shortcuts

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