boltTime

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

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

Go to latest
Published: Sep 13, 2017 License: MIT Imports: 2 Imported by: 0

README

boltTime

Time/Value database built on boltDB

Interface:
Put(bucket string, entry Entry) error
GetSince(bucket string, t time.Time) ([]Entry, error)
DeleteBefore(bucket string, t time.Time) error
GetLatestN(bucket string, n int) ([]Entry, error)

To get a new BoltTime instance:

    NewBoltTime(dbFile string) (*BoltTime, error)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltTime

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

BoltTime is a type that fulfils the TimeStore interface

func NewBoltTime

func NewBoltTime(dbFile string) (*BoltTime, error)

NewBoltTime returns a initialised BoltTime instance

func (*BoltTime) DeleteBefore

func (bt *BoltTime) DeleteBefore(bucket string, t time.Time) error

DeleteBefore deletes all entries before time t

func (*BoltTime) GetLatestN

func (bt *BoltTime) GetLatestN(bucket string, n int) (entries []Entry, err error)

GetLastestN retrieves n most recent entries

func (*BoltTime) GetSince

func (bt *BoltTime) GetSince(bucket string, t time.Time) (entries []Entry, err error)

GetSince returns all values since time t

func (*BoltTime) Put

func (bt *BoltTime) Put(bucket string, entry Entry) error

Put puts a Entry into the datastore in the specified bucket

type Entry

type Entry struct {
	Time  time.Time
	Value []byte
}

Entry contains a time and a []byte value

type TimeBucket

type TimeBucket interface {
	Put(bucket string, entry Entry) error

	Get(t time.Time) []Entry
	GetSince(t time.Time) []Entry
	GetBefore(t time.Time) []Entry
	GetNewestN(n int) []Entry
	GetOldestN(n int) []Entry

	Delete(t time.Time) error
	DeleteSince(t time.Time) error
	DeleteBefore(t time.Time) error
	DeleteNewestN(n int) error
	DeleteOldestN(n int) error
}

type TimeStore

type TimeStore interface {
	Put(bucket string, entry Entry) error
	GetSince(bucket string, t time.Time) ([]Entry, error)
	DeleteBefore(bucket string, t time.Time) error
	GetLatestN(bucket string, n int) ([]Entry, error)
}

TimeStore decribes the interface that BoltTime fulfils

Jump to

Keyboard shortcuts

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