MCPcopy Create free account
hub / github.com/MertJSX/folderhost / LifeCycle

Method LifeCycle

utils/cache/life_cycle.go:5–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import "time"
4
5func (c *Cache[KeyType, DataType]) LifeCycle() {
6 c.Mutex.Lock()
7 defer c.Mutex.Unlock()
8 unixtime := time.Now().Unix()
9 for key, item := range c.Items {
10 if item.LifeTime == 0 {
11 continue
12 }
13 if item.LifeTime < unixtime {
14 if c.Properties.TimeoutCacheEvent {
15 c.TimeoutCacheEvent <- CacheEvent[KeyType, DataType]{
16 Key: key,
17 Data: item.Data,
18 }
19 }
20 delete(c.Items, key)
21 }
22 }
23}

Callers 1

LoopMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected