Documentation
¶
Index ¶
- Constants
- type Cache
- type DefaultInMemCache
- func (d *DefaultInMemCache) Get(traceID string) *types.Trace
- func (d *DefaultInMemCache) GetAll() []*types.Trace
- func (d *DefaultInMemCache) GetCacheSize() int
- func (d *DefaultInMemCache) Set(trace *types.Trace) *types.Trace
- func (d *DefaultInMemCache) TakeExpiredTraces(now time.Time) []*types.Trace
Constants ¶
View Source
const DefaultInMemCacheCapacity = 10000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Set adds the trace to the cache. If it is kicking out a trace from the cache // that has not yet been sent, it will return that trace. Otherwise returns nil. Set(trace *types.Trace) *types.Trace Get(traceID string) *types.Trace // GetAll is used during shutdown to get all in-flight traces to flush them GetAll() []*types.Trace // Retrieve and remove all traces which are past their SendBy date. // Does not check whether they've been sent. TakeExpiredTraces(now time.Time) []*types.Trace }
Cache is a non-threadsafe cache. It must not be used for concurrent access.
type DefaultInMemCache ¶
type DefaultInMemCache struct { Metrics metrics.Metrics Logger logger.Logger // contains filtered or unexported fields }
DefaultInMemCache keeps a bounded number of entries to avoid growing memory forever. Traces are expunged from the cache in insertion order (not access order) so it is important to have a cache larger than trace throughput * longest trace.
func NewInMemCache ¶
func (*DefaultInMemCache) GetAll ¶
func (d *DefaultInMemCache) GetAll() []*types.Trace
GetAll is not thread safe and should only be used when that's ok Returns all non-nil trace entries.
func (*DefaultInMemCache) GetCacheSize ¶
func (d *DefaultInMemCache) GetCacheSize() int
func (*DefaultInMemCache) Set ¶
func (d *DefaultInMemCache) Set(trace *types.Trace) *types.Trace
Set adds the trace to the ring. If it is kicking out a trace from the ring that has not yet been sent, it will return that trace. Otherwise returns nil.
func (*DefaultInMemCache) TakeExpiredTraces ¶
func (d *DefaultInMemCache) TakeExpiredTraces(now time.Time) []*types.Trace
Click to show internal directories.
Click to hide internal directories.