// Package realtimedata define real time data operation functions package realtimedata import ( "time" ) // CacheItem define structure for caching real time data with calculation capabilities type CacheItem struct { key string value []any noticeChan chan struct{} calculatorFunc func(done chan struct{}, params []any) lastAccessed time.Time } // Reset defines func to reset the CacheItem to its zero state func (ci *CacheItem) Reset() { ci.key = "" ci.value = nil ci.noticeChan = nil ci.calculatorFunc = nil ci.lastAccessed = time.Time{} } // IsExpired defines func to check if the cache item has expired based on a given TTL func (ci *CacheItem) IsExpired(ttl time.Duration) bool { return time.Since(ci.lastAccessed) > ttl }