Back to godoc.org

Package data

v0.0.0-...-d8e89f0
Latest Go to latest

The highest tagged major version is .

Published: Sep 3, 2015 | License: MIT | Module: bitbucket.org/tshannon/freehold

Index

Variables

var ErrNotFound = errors.New("Value not found")

ErrNotFound is the error returned from a core datastore if a value is not found for the passed in key

func Close

func Close(name string)

Close closes an open datastore

func Create

func Create(name string) error

Create creates a new datastore

func Drop

func Drop(name string) error

Drop Delete deletes a datastore

func SetTimeout

func SetTimeout(timeout time.Duration)

SetTimeout sets the file timeout (when a datatstore file will auto close)

type CoreDS

type CoreDS struct {
	store.Storer
}

CoreDS is a wrapper of the store interface with a few handy things added for managing core datastores used for the operation of a freehold instance

func OpenCoreDS

func OpenCoreDS(filename string) (*CoreDS, error)

OpenCoreDS opens a Core datastore

func (*CoreDS) Delete

func (c *CoreDS) Delete(key interface{}) error

Delete deletes a key / value from the coreds

func (*CoreDS) Get

func (c *CoreDS) Get(key interface{}, result interface{}) error

Get retrieves a value from the core datastore

func (*CoreDS) MakeDatastore

func (c *CoreDS) MakeDatastore() *Datastore

MakeDatastore creates a datastore type from the core datastore

func (*CoreDS) Put

func (c *CoreDS) Put(key interface{}, value interface{}) error

Put puts a new key /value in the core datastore

type Data

type Data map[string]*json.RawMessage

Data is a generic key / value representation for JSON data the values we dont' acctual decode as it's just stored in the DS as raw JSON bytes anyway

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

Datastore holds data and an identifying key in json format in a file on the host

func Open

func Open(name string) (*Datastore, error)

Open opens an existing datastore file

func (*Datastore) Count

func (d *Datastore) Count(iter *Iter) (int, error)

Count returns the number of records in the datastore

func (*Datastore) Delete

func (d *Datastore) Delete(key *Key) error

Delete delets a value from the datastore

func (*Datastore) Get

func (d *Datastore) Get(key *Key) (*json.RawMessage, error)

Get gets a value out of a datastore

func (*Datastore) Iter

func (d *Datastore) Iter(iter *Iter) ([]KeyValue, error)

Iter returns the key value result set of the passed in json iterator

func (*Datastore) Max

func (d *Datastore) Max() (*Key, error)

Max gets the max value in the datastore

func (*Datastore) Min

func (d *Datastore) Min() (*Key, error)

Min gets the min value in the datastore

func (*Datastore) Put

func (d *Datastore) Put(data Data) []error

Put puts a new value or sets of values in the datastore

type Iter

type Iter struct {
	From   *Key   `json:"from,omitempty"`
	To     *Key   `json:"to,omitempty"`
	Skip   int    `json:"skip,omitempty"`
	Limit  int    `json:"limit,omitempty"`
	Regexp string `json:"regexp,omitempty"`
	Order  string `json:"order,omitempty"`
}

Iter is the json view of an iterator

type Key

type Key json.RawMessage

Key is type that tries to save keys in proper byte order if they are numbers, so they remain sortable It does this by testing whether or not the incoming key is a number if it is, then it'll pack the encoded value with big endian encoded float value at the lead for sorting for decoding it simply throws away that extra info

func (*Key) MarshalJSON

func (k *Key) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type KeyValue

type KeyValue struct {
	Key   *Key             `json:"key,omitempty"`
	Value *json.RawMessage `json:"value,omitempty"`
}

KeyValue is a JSON representation of a key value

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier