(key string, value T, expiredAt int64)
| 86 | } |
| 87 | |
| 88 | func (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 | |
| 110 | func (this *Cache[T]) IncreaseInt64(key string, delta T, expiredAt int64, extend bool) T { |
| 111 | if this.isDestroyed { |
nothing calls this directly
no test coverage detected