aggregator

package
v1.2.116 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator[T any] struct {
	// contains filtered or unexported fields
}

Aggregator is a synchronized map of items that can auto-expire once stale

func NewAggregator

func NewAggregator[T any](bulkSize int, timeout time.Duration) *Aggregator[T]

NewAggregator is a helper to create instance of the aggregator

func (*Aggregator[T]) Add

func (agg *Aggregator[T]) Add(item T)

Add item to the aggregator

func (*Aggregator[T]) Close

func (agg *Aggregator[T]) Close()

Close calls Purge, and then stops the goroutine that does ttl checking, for a clean shutdown. The cache is no longer cleaning up after the first call to Close, repeated calls are safe though.

func (*Aggregator[T]) Count

func (agg *Aggregator[T]) Count() int

Count returns the number of items in the aggregator

func (*Aggregator[T]) Purge

func (agg *Aggregator[T]) Purge()

Purge will remove all entries

func (*Aggregator[T]) SetBulkCallback

func (agg *Aggregator[T]) SetBulkCallback(callback bulkCallback[T])

SetBulkCallback sets the callback on bulk creation

func (*Aggregator[T]) SetTimeoutCallback

func (agg *Aggregator[T]) SetTimeoutCallback(callback timeoutCallback[T])

SetTimeoutCallback sets the callback on timeout

Jump to

Keyboard shortcuts

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