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

Method Write

internal/ttlcache/cache.go:88–108  ·  view source on GitHub ↗
(key string, value T, expiredAt int64)

Source from the content-addressed store, hash-verified

86}
87
88func (this *Cache[T]) Write(key string, value T, expiredAt int64) (ok bool) {
89 if this.isDestroyed {
90 return
91 }
92
93 var currentTimestamp = fasttime.Now().Unix()
94 if expiredAt <= currentTimestamp {
95 return
96 }
97
98 var maxExpiredAt = currentTimestamp + 30*86400
99 if expiredAt > maxExpiredAt {
100 expiredAt = maxExpiredAt
101 }
102 var uint64Key = HashKeyString(key)
103 var pieceIndex = uint64Key % this.countPieces
104 return this.pieces[pieceIndex].Add(uint64Key, &Item[T]{
105 Value: value,
106 expiredAt: expiredAt,
107 })
108}
109
110func (this *Cache[T]) IncreaseInt64(key string, delta T, expiredAt int64, extend bool) T {
111 if this.isDestroyed {

Callers

nothing calls this directly

Calls 4

NowFunction · 0.92
HashKeyStringFunction · 0.85
UnixMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected