store

package
v0.0.0-...-d8e89f0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(name string)

Close / finish writes on a file

func Create

func Create(name string) error

Create creates a new store file

func Drop

func Drop(name string) error

Drop deletes a store file

func Halt

func Halt()

Halt closes all open datastore files

func SetFileTimeout

func SetFileTimeout(newTimeout time.Duration)

SetFileTimeout sets when the file will automatically close after the timeout duration has passed with no activity on the datastore file. Any new activity will restart the timeout. Shorter timeout means fewer open files, but less concurrency due to locking on open.

func Timeout

func Timeout() time.Duration

Timeout returns the current file timeout value

Types

type DS

type DS struct {
	*bolt.DB
	// contains filtered or unexported fields
}

DS is a datstore, holds the pointer to the underlying kv file, and keeps track of when a file times-out and needs to be closed and when it's in use

func (*DS) Delete

func (d *DS) Delete(key []byte) error

Delete deletes a value from the datastore

func (*DS) Get

func (d *DS) Get(key []byte) ([]byte, error)

Get get's a value from the datastore

func (*DS) Iter

func (d *DS) Iter(from, to []byte) (Iterator, error)

Iter returns an iteratore for the datastore

func (*DS) Max

func (d *DS) Max() ([]byte, error)

Max returns the max value in the datastore

func (*DS) Min

func (d *DS) Min() ([]byte, error)

Min returns the min value in the datastore

func (*DS) Put

func (d *DS) Put(key, value []byte) error

Put puts a new value in the datastore

type Iterator

type Iterator interface {
	Next() bool
	Key() []byte
	Value() []byte
	Err() error
	Close() error
}

Iterator is used for iterating through a range of keys in a datastore

type KvIterator

type KvIterator struct {
	*bolt.Cursor
	// contains filtered or unexported fields
}

KvIterator is a key value iterator

func (*KvIterator) Close

func (i *KvIterator) Close() error

Close closes the iterator

func (*KvIterator) Err

func (i *KvIterator) Err() error

Err returns any errors that may have happened during iterating

func (*KvIterator) Key

func (i *KvIterator) Key() []byte

Key gets the current key in the iterator

func (*KvIterator) Next

func (i *KvIterator) Next() bool

Next gets the next value from the iterator

func (*KvIterator) Value

func (i *KvIterator) Value() []byte

Value returns the current value in the iterator

type Storer

type Storer interface {
	Get(key []byte) ([]byte, error)
	Put(key, value []byte) error
	Delete(key []byte) error
	Max() ([]byte, error) //Max Key in store
	Min() ([]byte, error) //Min Key in store
	Iter(from, to []byte) (Iterator, error)
}

Storer is the interface that is needed to run a freehold instance an any datastores in it

func Open

func Open(name string) (Storer, error)

Open opens an existing store file, if the file is currently open then it passes back the current pointer to the store

Jump to

Keyboard shortcuts

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