Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 committed Jul 17, 2024
1 parent 8627f11 commit 112f824
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lru/lru_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,28 @@ func (c *cacheBase) Get(key string) (value interface{}, ok bool) {
if c.Expiry != time.Duration(0) {
unixNow := time.Now().UnixNano() / int64(time.Millisecond)
unixExpiry := int64(c.Expiry / time.Millisecond)
if (unixNow - ele.Value.(*entry).timeInsert) > unixExpiry {
c.removeElement(ele)
return nil, false
if ent, ok := ele.Value.(*entry); ok {
if (unixNow - ent.timeInsert) > unixExpiry {
c.removeElement(ele)
return nil, false
}
}
}
c.ll.MoveToFront(ele)
return ele.Value.(*entry).value, true
if ent, ok := ele.Value.(*entry); ok {
return ent.value, true
}
}
return nil, false
}

// Updates element's value without updating its "Least-Recently-Used" status
func (c *cacheBase) UpdateElement(key string, value interface{}) {
func (c *cacheBase) Set(key string, value interface{}) {
if ee, ok := c.cache[key]; ok {
ee.Value.(*entry).value = value
return
if ent, ok := ee.Value.(*entry); ok {
ent.value = value
return
}
}
}

Expand Down

0 comments on commit 112f824

Please sign in to comment.