Skip to content

Commit

Permalink
[patch] change delete logic (#64)
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
Yusuke Kato authored May 30, 2019
1 parent eaf3088 commit ab50832
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions gache.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,8 @@ func Set(key string, val interface{}) {

// Delete deletes value from Gache using key
func (g *gache) Delete(key string) {
for {
if v := atomic.LoadUint64(&g.l); atomic.CompareAndSwapUint64(&g.l, v, v-1) {
g.shards[xxhash.Sum64(*(*[]byte)(unsafe.Pointer(&key)))&mask].Delete(key)
return
}
}
atomic.AddUint64(&g.l, ^uint64(0))
g.shards[xxhash.Sum64(*(*[]byte)(unsafe.Pointer(&key)))&mask].Delete(key)
}

// Delete deletes value from Gache using key
Expand Down

0 comments on commit ab50832

Please sign in to comment.