MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / DeleteExpired

Method DeleteExpired

pkg/util/cache/cache.go:949–966  ·  view source on GitHub ↗

Delete all expired items from the cache.

()

Source from the content-addressed store, hash-verified

947
948// Delete all expired items from the cache.
949func (c *cache) DeleteExpired() {
950 var evictedItems []keyAndValue
951 now := time.Now().UnixNano()
952 c.mu.Lock()
953 for k, v := range c.items {
954 // "Inlining" of expired
955 if v.Expiration > 0 && now > v.Expiration {
956 ov, evicted := c.delete(k)
957 if evicted {
958 evictedItems = append(evictedItems, keyAndValue{k, ov})
959 }
960 }
961 }
962 c.mu.Unlock()
963 for _, v := range evictedItems {
964 c.onEvicted(v.key, v.value)
965 }
966}
967
968// Sets an (optional) function that is called with the key and value when an
969// item is evicted from the cache. (Including when it is deleted manually, but

Callers 2

RunMethod · 0.80

Calls 2

deleteMethod · 0.95
LockMethod · 0.80

Tested by 1