Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions gache.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,9 @@ func (g *gache[V]) set(key string, val V, expire int64) {
}
shard := g.shards[getShardID(key, g.maxKeyLength)]
newVal := g.valPool.Get().(*value[V])
newVal.mu.Lock()
newVal.key = key
newVal.val = val
atomic.StoreInt64(&newVal.expire, expire)
newVal.mu.Unlock()
old, loaded := shard.SwapPointer(key, newVal)
if loaded {
old.reset()
Expand Down Expand Up @@ -905,11 +903,9 @@ func (g *gache[V]) ExtendExpire(key string, addExp time.Duration) {
var copied bool
val.mu.RLock()
if val.key == key {
newVal.mu.Lock()
newVal.key = key
newVal.val = val.val
atomic.StoreInt64(&newVal.expire, atomic.LoadInt64(&val.expire)+int64(addExp))
newVal.mu.Unlock()
copied = true
}
val.mu.RUnlock()
Expand Down Expand Up @@ -988,11 +984,9 @@ func (g *gache[V]) GetRefreshWithDur(key string, d time.Duration) (v V, ok bool)
var copied bool
val.mu.RLock()
if val.key == key {
newVal.mu.Lock()
newVal.key = key
newVal.val = val.val
atomic.StoreInt64(&newVal.expire, fastime.UnixNanoNow()+int64(d))
newVal.mu.Unlock()
v = newVal.val
copied = true
}
Expand Down Expand Up @@ -1114,11 +1108,9 @@ func (g *gache[V]) SetWithExpireIfNotExists(key string, val V, d time.Duration)
}

newVal := g.valPool.Get().(*value[V])
newVal.mu.Lock()
newVal.key = key
newVal.val = val
atomic.StoreInt64(&newVal.expire, exp)
newVal.mu.Unlock()

shard := g.shards[getShardID(key, g.maxKeyLength)]
for {
Expand Down
Loading