1 Commits

Author SHA1 Message Date
c200f51afd bug fixes 2022-02-24 21:50:54 -08:00
4 changed files with 1 additions and 12 deletions

2
go.mod
View File

@@ -2,4 +2,4 @@ module git.wntrmute.dev/kyle/go-mru
go 1.17 go 1.17
require github.com/benbjohnson/clock v1.3.5 require github.com/benbjohnson/clock v1.3.0

2
go.sum
View File

@@ -1,2 +0,0 @@
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=

4
mru.go
View File

@@ -53,10 +53,6 @@ func (c *Cache) Len() int {
// evict should remove the least-recently-used cache item. // evict should remove the least-recently-used cache item.
func (c *Cache) evict() { func (c *Cache) evict() {
if c.access.Len() == 0 {
return
}
k := c.access.K(0) k := c.access.K(0)
c.evictKey(k) c.evictKey(k)
} }

View File

@@ -20,11 +20,6 @@ func TestBasicCacheEviction(t *testing.T) {
t.Fatal("cache should have size 0") t.Fatal("cache should have size 0")
} }
c.evict()
if err := c.ConsistencyCheck(); err != nil {
t.Fatal(err)
}
c.Store("raven", 1) c.Store("raven", 1)
if err := c.ConsistencyCheck(); err != nil { if err := c.ConsistencyCheck(); err != nil {
t.Fatal(err) t.Fatal(err)