kv

package
v0.0.0-...-9d8ded8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 0 Imported by: 3

Documentation

Overview

Package kv provides a generic interface around kv stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV interface {
	// Get gets the value of the given key.
	Get(string) ([]byte, error)
	// Put puts the value of the given key.
	Put(string, []byte) error
	// Exists reports whether the given key exists.
	Exists(string) (bool, error)
	// List lists all the keys under the given prefix.
	List(string) (map[string][]byte, error)
	// NewLocker creates a new Locker.
	NewLocker(string) Locker
	// NewWatcher create a new Watcher.
	NewWatcher(string) Watcher
	// Delete deletes the given key.
	Delete(string) error
	// DeleteTree deletes all the keys under the given prefix.
	DeleteTree(string) error
}

KV represents a kv store.

type Locker

type Locker interface {
	// Lock acquires the lock and blocks while doing so.
	Lock() error
	// Unlock releases the lock.
	Unlock() error
}

Locker represents a distributed lock.

type Watcher

type Watcher interface {
	// Watch start to watch (prefix does not need to exist).
	// Returns a map of all the keys under the given prefix.
	Watch() (<-chan map[string][]byte, error)
	// Unwatch stop watching.
	Unwatch() error
}

Watcher represents a monitor for changes.

Directories

Path Synopsis
consul module
etcd module
redis module

Jump to

Keyboard shortcuts

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