Versions in this module Expand all Collapse all v1 v1.0.0 Sep 29, 2024 Changes in this version + var IdxCmp = time.Time.Compare + func CreateConvertorToString[Val any]() func(Val) string + type Cache interface + Close func() + Get func(key Key, periodStart, periodEnd time.Time, extra interface{}) ([]Data, error) + GetCached func(key Key, periodStart, periodEnd time.Time) ([]Data, bool, error) + GetCachedAll func(key Key, ...) (CacheStateSegment[Data], bool, error) + GetCachedPeriodClosestFromEnd func(key Key, point time.Time, nonEmpty bool) (*TimePeriodBounds[Data], error) + GetCachedPeriodClosestFromStart func(key Key, point time.Time, nonEmpty bool) (*TimePeriodBounds[Data], error) + type CacheBase struct + func NewCacheBase[Data any, Key any](opts CacheBaseOptions[Data, Key]) *CacheBase[Data, Key] + func (c *CacheBase[Data, Key]) Close() + func (c *CacheBase[Data, Key]) Get(key Key, periodStart, periodEnd time.Time, extra interface{}) ([]Data, error) + func (c *CacheBase[Data, Key]) GetCached(key Key, periodStart, periodEnd time.Time) ([]Data, bool, error) + func (c *CacheBase[Data, Key]) GetCachedAll(key Key, ...) (CacheStateSegment[Data], bool, error) + func (c *CacheBase[Data, Key]) GetCachedPeriodClosestFromEnd(key Key, point time.Time, nonEmpty bool) (*TimePeriodBounds[Data], error) + func (c *CacheBase[Data, Key]) GetCachedPeriodClosestFromStart(key Key, point time.Time, nonEmpty bool) (*TimePeriodBounds[Data], error) + type CacheBaseOptions struct + GetFromSource CacheSource[Data, Key] + GetTimestamp func(d *Data) time.Time + KeyToStr func(Key) string + SkipDataVerification bool + Storage CacheStorage[Data, Key] + type CacheData sparse.SeriesData[Data, time.Time] + type CacheSource func(key Key, periodStart, periodEnd time.Time, ...) (CacheStateSegment[Data], error) + type CacheState sparse.SeriesState[Data, time.Time] + type CacheStateSegment struct + Data []Data + PeriodEnd time.Time + PeriodStart time.Time + type CacheStorage interface + Add func(key Key, periodStart, periodEnd time.Time, data []Data) (CacheData[Data], error) + Load func(key Key) (*CacheState[Data], error) + Save func(key Key, state *CacheState[Data], updated []*CacheStateSegment[Data]) error + type FileCache struct + func NewFileCache[Data any, Key any](opts FileCacheOptions[Data, Key]) (*FileCache[Data, Key], error) + type FileCacheOptions struct + CacheDir string + GetFromSource CacheSource[Data, Key] + GetTimestamp func(d *Data) time.Time + KeyToStr func(Key) string + SkipDataVerification bool + type LoadCaheFunc func(key Key) (*MemoryCacheState[Data], error) + type MemoryAndSqliteCache struct + func NewMemoryAndSqliteCache[Data any, Key any, ID comparable](opts MemoryAndSqliteCacheOptions[Data, Key, ID]) (*MemoryAndSqliteCache[Data, Key, ID], error) + type MemoryAndSqliteCacheOptions struct + MinFirstLayerFetchPeriod time.Duration + type MemoryCache struct + func NewMemoryCache[Data any, Key any](opts MemoryCacheOptions[Data, Key]) *MemoryCache[Data, Key] + type MemoryCacheOptions struct + GetFromSource CacheSource[Data, Key] + GetTimestamp func(d *Data) time.Time + KeyToStr func(Key) string + Load LoadCaheFunc[Data, Key] + Save SaveCacheFunc[Data, Key] + SkipDataVerification bool + type MemoryCacheState struct + Segments []*CacheStateSegment[Data] + type PeriodBounds = sparse.PeriodBounds[time.Time] + type SaveCacheFunc func(key Key, state *CacheState[Data], updated []*CacheStateSegment[Data]) error + type SqliteCache struct + func NewSqliteCache[Data any, Key any, ID comparable](opts SqliteCacheOptions[Data, Key, ID]) (*SqliteCache[Data, Key, ID], error) + type SqliteCacheOptions struct + CacheDir string + GetFromSource CacheSource[Data, Key] + GetID func(d *Data) ID + GetTimestamp func(d *Data) time.Time + KeyToStr func(Key) string + SkipDataVerification bool + type TimePeriodBounds struct + First *Data + Last *Data