nictuku / dht

Kademlia/Mainline DHT node in Go.
Other
826 stars 144 forks source link

package nettools needs to be updated as LRUCache struct was changed ... #73

Open kendrickjung opened 3 years ago

kendrickjung commented 3 years ago

https://github.com/vitessio/vitess/blob/master/go/cache/lru_cache.go they have added a cost

type LRUCache struct { mu sync.Mutex // list & table contain entry objects. list list.List table map[string]*list.Element cost func(interface{}) int64 size int64 capacity int64 evictions int64 }

kendrickjung commented 3 years ago

My guess is that in the package https://github.com/nictuku/nettools/blob/master/ratelimit.go cache.NewLRUCache(maxHosts) needs to be repalced by cache.NewLRUCache(maxHosts,cacheValueSize)

func cacheValueSize(val interface{}) int64 { return val.(*CacheValue).size }

ghost commented 3 years ago

Personally I fixed that in the package https://github.com/nictuku/nettools/blob/master/ratelimit.go as follow: func cacheValueSize(val interface{}) int64 { return 8 } and replaced cache.NewLRUCache(maxHosts) by cache.NewLRUCache(maxHosts,cacheValueSize)