KV

package module
v0.0.0-...-5c890a4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DiskLess is used to set if running in non database filename mode.
	DiskLess bool
	// DatabasePath is used to identify database filename and path.
	// Set unique path to avoid database file collision.
	DatabasePath string
}

Config describes configuration of a namespace.

type NameSpace

type NameSpace struct {
	Config
	// contains filtered or unexported fields
}

NameSpace defines a storage space.

func NewNameSpace

func NewNameSpace(c Config) *NameSpace

NewNameSpace creates a new namespace for storing key-value data.

func (*NameSpace) Delete

func (ns *NameSpace) Delete(key []byte) error

Delete removes given key from namespace.

func (*NameSpace) Get

func (ns *NameSpace) Get(key []byte) ([]byte, error)

Get obtains value with given key from the namespace.

func (*NameSpace) Put

func (ns *NameSpace) Put(key, val []byte, ttl time.Duration) error

Put stores given key and value in the namespace. Stored data will be deleted after ttl period. Set ttl to 0 for disabling auto-delete.

Jump to

Keyboard shortcuts

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