cache

package
v0.0.0-...-8c3ffa5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cache provides a cache to query stock measures, without exceeding free usage of the quandl webservice. Cache is implemented as a sqlite db in a local file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// database for caching
	*gorm.DB
	// contains filtered or unexported fields
}

Cache is the DB access object used to cach or retrieve data.

func NewCache

func NewCache(conf configuration.Conf) *Cache

NewCache creates a new file-based cache, locally.

func NewMemoryCache

func NewMemoryCache(conf configuration.Conf) *Cache

NewMemoryCache creates a Cache in memory. Mainly used for testing.

func (*Cache) Close

func (c *Cache) Close() error

Close the underlying database. Required to flush the cache when file.

func (*Cache) Dump

func (c *Cache) Dump()

Dump dumps the data base. Used for testing/debugging.

func (*Cache) ListTickers

func (c *Cache) ListTickers() []string

ListTickers will list the tickers managed in the cache in a thread safe way.

func (*Cache) MostRecent

func (c *Cache) MostRecent(ticker string) time.Time

MostRecent is the most recent date for that ticker in the database.

func (*Cache) Refresh

func (c *Cache) Refresh()

Refresh the cache, if needed, for all tickers.

func (*Cache) Size

func (c *Cache) Size() (n int)

Size provides count of total records in cache.

type Measure

type Measure string

Measure defines the various values taht can be retrieved from the database.

const (
	Open     Measure = "OPEN"
	Close    Measure = "LAST" // alias
	Last     Measure = "LAST"
	High     Measure = "HIGH"
	Low      Measure = "LOW"
	Volume   Measure = "VOLUME"
	Turnover Measure = "TURNOVER"
)

Predefined measures

Jump to

Keyboard shortcuts

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