boltdb

package
v0.0.0-...-360b30e Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(path string) (storage.Storage, error)

New creates and initialises a new Closer persisted in Bolt.

Example
path := getTmpPath()
defer os.Remove(path)

storage, err := New(path)

if err != nil {
	log.Fatal(err)
}

defer storage.Close()

storage.LoadOrStore("foo", "bar")
key, _ := storage.Resolve("bar")

fmt.Printf("Key for 'bar' is '%s'\n", key)
Output:

Key for 'bar' is 'foo'
Example (Other)
path := getTmpPath()
defer os.Remove(path)

storage, _ := New(path) // We ignore the error this time. Naughty!
defer storage.Close()

storage.LoadOrStore("foo", "bar")

value, loaded := storage.LoadOrStore("foo", "42")
key, _ := storage.Resolve("bar")

fmt.Printf("Value of 'foo' is '%s'\n", value)
fmt.Printf("Value of 'foo' was loaded from storage: %t\n", loaded)
fmt.Printf("Key for 'bar' is '%s'\n", key)

_, ok := storage.Resolve("42")

fmt.Printf("Key for '42' could be resolved: %t", ok)
Output:

Value of 'foo' is 'bar'
Value of 'foo' was loaded from storage: true
Key for 'bar' is 'foo'
Key for '42' could be resolved: false

Types

This section is empty.

Jump to

Keyboard shortcuts

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