phuslu / lru

High performance LRU cache
MIT License
206 stars 8 forks source link

节点长度计算不正确 #17

Open movsb opened 4 months ago

movsb commented 4 months ago

测试代码:

package main

import (
    "fmt"
    "time"

    "github.com/phuslu/lru"
)

func main() {
    cache := lru.NewTTLCache[int, int](1024)
    for i := 0; i < 1000; i++ {
        cache.Set(i, i, time.Hour)
    }
    fmt.Println(cache.Len())
}

运行输出:

tests (main) → go run main.go
999

期待输出 1000.

wy15 commented 1 month ago

cache.Set(0,0,time.Hour) not work

godruoyi commented 3 weeks ago

I am interested this issue and will take some time to investigate it, hope I can get the root cause, but it would be better if we get some suggestions for @phuslu.