cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Index

Constants

View Source
const SHARD_COUNT = 256

Variables

View Source
var (
	Caches caches
	Config CacheSection
)
View Source
var FlushDoneChan chan int
View Source
var (
	TotalCount int64
)

Functions

func GetChunkIndex

func GetChunkIndex(key interface{}, size int) (uint32, error)

func Init

func Init(cfg CacheSection)

func InitCaches

func InitCaches()

func InitChunkSlot

func InitChunkSlot()

func NewCaches

func NewCaches() caches

func StartCleanup

func StartCleanup()

Types

type CS

type CS struct {
	Chunks          []*Chunk
	CurrentChunkPos int

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewChunks

func NewChunks(numOfChunks int) *CS

func (*CS) Get

func (cs *CS) Get(from, to int64) []Iter

func (CS) GetChunk

func (cs CS) GetChunk(pos int) *Chunk

func (*CS) GetFlag

func (cs *CS) GetFlag() uint32

func (*CS) GetInfo

func (cs *CS) GetInfo() (uint32, uint32)

GetInfo get oldest ts and newest ts in cache

func (*CS) GetInfoUnsafe

func (cs *CS) GetInfoUnsafe() (uint32, uint32)

func (*CS) Push

func (cs *CS) Push(seriesID interface{}, ts int64, value float64) error

func (*CS) SetFlag

func (cs *CS) SetFlag(flag uint32)

type CacheSection

type CacheSection struct {
	KeepMinutes      int `yaml:"keepMinutes"`
	SpanInSeconds    int `yaml:"spanInSeconds"`
	NumOfChunks      int `yaml:"numOfChunks"`
	DoCleanInMinutes int `yaml:"doCleanInMinutes"`
	FlushDiskStepMs  int `yaml:"flushDiskStepMs"`
}

type Chunk

type Chunk struct {
	tsz.Series
	FirstTs   uint32
	LastTs    uint32
	NumPoints uint32
	Closed    bool
}

func NewChunk

func NewChunk(t0 uint32) *Chunk

func (*Chunk) FinishSync

func (c *Chunk) FinishSync()

func (*Chunk) Push

func (c *Chunk) Push(t uint32, v float64) error

type ChunksSlot

type ChunksSlot struct {
	sync.RWMutex
	Data []map[interface{}][]*Chunk
	Size int
}
var ChunksSlots *ChunksSlot

func (*ChunksSlot) Get

func (c *ChunksSlot) Get(idx int) map[interface{}][]*Chunk

func (*ChunksSlot) GetChunks

func (c *ChunksSlot) GetChunks(key interface{}) ([]*Chunk, bool)

func (*ChunksSlot) Len

func (c *ChunksSlot) Len(idx int) int

func (*ChunksSlot) Push

func (c *ChunksSlot) Push(key interface{}, val *Chunk)

func (*ChunksSlot) PushChunks

func (c *ChunksSlot) PushChunks(key interface{}, vals []*Chunk)

type Iter

type Iter struct {
	*tsz.Iter
}

func NewIter

func NewIter(i *tsz.Iter) Iter

type Point

type Point struct {
	Key       interface{} `msg:"key"`
	Timestamp int64       `msg:"timestamp"`
	Value     float64     `msg:"value"`
}

Jump to

Keyboard shortcuts

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