timeseries

package module
v0.0.0-...-c4fd474 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: MIT Imports: 7 Imported by: 0

README

go-redis-timeseries

Save time-series data to redis. This code is inspired by https://github.com/antirez/redis-timeseries/pull/1/files.

Usage

See Example.

Remember, this implementation is using Redis Sorted Set, so if you save an exact data more than one, sorted set only have a single copy of this data. One solution to overcome this limitation is to include timestamp in your data.

Disclaimer

The code in this repo has not been fully tested. Use at your own risk.

License

MIT Public License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

Functions

This section is empty.

Types

type TimeSeries

type TimeSeries struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TimeSeries is use to save time series data to redis

func NewTimeSeries

func NewTimeSeries(prefix string, timestep time.Duration, exp time.Duration, db redis.Conn) *TimeSeries

NewTimeSeries create new TimeSeries

func (*TimeSeries) Add

func (t *TimeSeries) Add(data interface{}, tm ...time.Time) (err error)

Add add data to timeseries db

func (*TimeSeries) Fetch

func (t *TimeSeries) Fetch(tm time.Time, dest interface{}) (err error)

Fetch get value one time

func (*TimeSeries) FetchRange

func (t *TimeSeries) FetchRange(begin, end time.Time, dest interface{}) (err error)

FetchRange fetch data from the begin time to end time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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