Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lixizan committed Nov 3, 2023
1 parent 50ef58e commit a544741
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func (c *MemoryCache) Get(key string) (v any, exist bool) {
var b = c.getBucket(key)
b.Lock()
defer b.Unlock()
result, exist := c.fetch(c.getBucket(key), key)
if !exist {
result, ok := c.fetch(c.getBucket(key), key)
if !ok {
return nil, false
}
return result.Value, true
Expand All @@ -200,8 +200,8 @@ func (c *MemoryCache) GetWithTTL(key string, exp time.Duration) (v any, exist bo
b.Lock()
defer b.Unlock()

result, exist := c.fetch(c.getBucket(key), key)
if !exist {
result, ok := c.fetch(b, key)
if !ok {
return nil, false
}

Expand All @@ -224,7 +224,7 @@ func (c *MemoryCache) GetOrCreateWithCallback(key string, value any, exp time.Du
defer b.Unlock()

expireAt := c.getExp(exp)
result, ok := c.fetch(c.getBucket(key), key)
result, ok := c.fetch(b, key)
if ok {
result.ExpireAt = expireAt
b.Heap.Down(result.index, b.Heap.Len())
Expand All @@ -244,7 +244,7 @@ func (c *MemoryCache) Delete(key string) (deleted bool) {
b.Lock()
defer b.Unlock()

v, ok := b.Map[key]
v, ok := c.fetch(b, key)
if !ok {
return false
}
Expand Down

0 comments on commit a544741

Please sign in to comment.