phuslu / lru

High performance LRU cache
MIT License
182 stars 6 forks source link

why crash? #12

Closed ouvaa closed 3 months ago

ouvaa commented 3 months ago

do u know what's wrong?

2024/03/28 16:10:44 started redhub server at 127.0.0.1:6380
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6e7ca2]

goroutine 10 [running]:
github.com/phuslu/lru.(*LRUCache[...]).Get(0x814a80, {0xc00034a012, 0x10})
    /root/go/pkg/mod/github.com/phuslu/lru@v1.0.12/lru_cache.go:71 +0x22

code attached: https://pastebin.com/DYD0sku7

redis-cli -p 6380
127.0.0.1:6380> set a b
Error: Server closed the connection
phuslu commented 3 months ago
var cache *phuslu.LRUCache[string,string]

should be

var cache = phuslu.NewLRUCache[string,string](10000)
ouvaa commented 3 months ago

ok. sry, thx