nuts

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateOk uint32 = iota
	StateBreak
)
View Source
const (
	// FileIO represents the read and write mode using standard I/O.
	FileIO = nutsdb.FileIO

	// MMap represents the read and write mode using mmap.
	MMap = nutsdb.MMap
)
View Source
const WatcherNotifyBufferSize = 32

Variables

View Source
var (
	KeyInitBucket = []byte("_init_key")
	ErrStateBreak = errors.New("state break")
)

Functions

func BackupReader

func BackupReader(dst string, src io.Reader) error

func BackupWriter

func BackupWriter(src string, dst io.Writer) error

func DisableStrictMode

func DisableStrictMode()

func EnableStrictMode

func EnableStrictMode()

func New

func New(cfg Config) (store.Store, error)

func PrefixKey

func PrefixKey(prefix []byte) string

func ReadTTL

func ReadTTL(md *nutsdb.MetaData) uint32

func WatchKey

func WatchKey(key []byte) (hash uint64)

WatchKey from: https://en.wikipedia.org/wiki/Jenkins_hash_function (Jenkins' One-At-A-Time hashing)

Types

type Config

type Config struct {
	NodeNum int64
	Sync    bool
	DataDir string
	RWMode  RWMode
}

type DB

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

func (*DB) Begin

func (s *DB) Begin(writable bool) (*nutsdb.Tx, error)

func (*DB) Break

func (s *DB) Break(ctx context.Context) error

func (*DB) Close

func (s *DB) Close() error

func (*DB) Current

func (s *DB) Current() string

func (*DB) DB

func (s *DB) DB() (*nutsdb.DB, error)

func (*DB) Del

func (s *DB) Del(key []byte) error

func (*DB) Get

func (s *DB) Get(key []byte) (*store.Value, error)

func (*DB) PrefixScan

func (s *DB) PrefixScan(prefix []byte, offset, limit int) ([]*store.Value, error)

func (*DB) PrefixSearchScan

func (s *DB) PrefixSearchScan(prefix []byte, reg string, offset, limit int) ([]*store.Value, error)

func (*DB) Restore

func (s *DB) Restore(src io.Reader) (err error)

func (*DB) Set

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

func (*DB) SetWithTTL

func (s *DB) SetWithTTL(key, value []byte, ttl uint32) error

func (*DB) Snapshot

func (s *DB) Snapshot() (io.Reader, error)

func (*DB) State

func (s *DB) State() uint32

func (*DB) Swap

func (s *DB) Swap(namespace string) (store.Actions, error)

func (*DB) Transaction

func (s *DB) Transaction(writable bool, fn func(tx *nutsdb.Tx) error) error

func (*DB) TrySet

func (s *DB) TrySet(key, value []byte) error

func (*DB) TrySetWithTTL

func (s *DB) TrySetWithTTL(key, value []byte, ttl uint32) error

func (*DB) Watch

func (s *DB) Watch(key []byte) (store.Watcher, error)

func (*DB) WatchPrefix

func (s *DB) WatchPrefix(prefix []byte) store.Watcher

type RWMode

type RWMode = nutsdb.RWMode

RWMode represents the read and write mode.

type Watcher

type Watcher struct {
	Namespaces sync.Map // map[string]*WatcherChild
}

func (*Watcher) UseTarget

func (w *Watcher) UseTarget(namespace string) *WatcherChild

type WatcherChannel

type WatcherChannel struct {
	PrefixWatch bool

	Value  *[]byte
	Prefix []byte
	Notify sync.Map // map[string]*WatcherNotifier
	// contains filtered or unexported fields
}

func (*WatcherChannel) AddNotifier

func (c *WatcherChannel) AddNotifier(dest *WatcherNotifier)

func (*WatcherChannel) TryUpdate

func (c *WatcherChannel) TryUpdate(key []byte, value *[]byte, ttl uint32)

type WatcherChild

type WatcherChild struct {
	Namespace      string
	Channels       sync.Map // map[uint64]*WatcherChannel
	PrefixChannels sync.Map // map[string]*WatcherChannel
}

func (*WatcherChild) Update

func (c *WatcherChild) Update(key, value []byte, ttl uint32)

func (*WatcherChild) Watch

func (c *WatcherChild) Watch(key []byte) *WatcherNotifier

func (*WatcherChild) WatchPrefix

func (c *WatcherChild) WatchPrefix(prefix []byte) *WatcherNotifier

type WatcherNotifier

type WatcherNotifier struct {
	Values chan *store.WatchValue
	UUID   string
	// contains filtered or unexported fields
}

func (*WatcherNotifier) Close

func (n *WatcherNotifier) Close() error

func (*WatcherNotifier) Notify

func (n *WatcherNotifier) Notify() chan *store.WatchValue

Jump to

Keyboard shortcuts

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