persist

package
v0.4.7-beta Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilEntry  = errors.New("entry does not exist")
	ErrNilBucket = errors.New("bucket does not exist")
)
View Source
var (
	ErrBadVersion = errors.New("incompatible version")
	ErrBadHeader  = errors.New("wrong header")
)
View Source
var NilDB nildb

NilDB is a db whose methods are no-ops. Calls to Block will return the zero value of types.Block. Calls to Height will return 0.

Functions

func Load added in v0.3.3

func Load(meta Metadata, data interface{}, r io.Reader) error

Load loads json data from a reader.

func LoadFile added in v0.3.3

func LoadFile(meta Metadata, data interface{}, filename string) error

LoadFile loads json data from a file.

func NewSafeFile added in v1.0.0

func NewSafeFile(filename string) (*safeFile, error)

func RandomSuffix added in v1.0.0

func RandomSuffix() string

RandomSuffix returns a 20 character base32 suffix for a filename. There are 100 bits of entropy, and a very low probability of colliding with existing files unintentionally.

func Save added in v0.3.3

func Save(meta Metadata, data interface{}, w io.Writer) error

Save saves json data to a writer.

func SaveFile added in v0.3.3

func SaveFile(meta Metadata, data interface{}, filename string) error

SaveFile saves json data to a file.

Types

type BoltDatabase added in v1.0.0

type BoltDatabase struct {
	Metadata
	*bolt.DB
}

func OpenDatabase added in v1.0.0

func OpenDatabase(md Metadata, filename string) (*BoltDatabase, error)

openDatabase opens a database filename and checks metadata

func (*BoltDatabase) CloseDatabase

func (db *BoltDatabase) CloseDatabase() error

CloseDatabase saves the bolt database to a file, and updates metadata

type Metadata added in v0.3.3

type Metadata struct {
	Header, Version string
}

Metadata contains the header and version of the data being stored.

Jump to

Keyboard shortcuts

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