MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / WithGC

Method WithGC

internal/utils/counters/counter.go:55–67  ·  view source on GitHub ↗

WithGC start the counter with gc automatically

()

Source from the content-addressed store, hash-verified

53
54// WithGC start the counter with gc automatically
55func (this *Counter[T]) WithGC() *Counter[T] {
56 if this.gcTicker != nil {
57 return this
58 }
59 this.gcTicker = time.NewTicker(1 * time.Second)
60 goman.New(func() {
61 for range this.gcTicker.C {
62 this.GC()
63 }
64 })
65
66 return this
67}
68
69// Increase key
70func (this *Counter[T]) Increase(key uint64, lifeSeconds int) T {

Callers 2

TestCounter_GC2Function · 0.80
counter.goFile · 0.80

Calls 2

GCMethod · 0.95
NewFunction · 0.92

Tested by 1

TestCounter_GC2Function · 0.64