dht icon indicating copy to clipboard operation
dht copied to clipboard

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

Open kendrickjung opened this issue 4 years ago • 2 comments

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 avatar Feb 16 '21 15:02 kendrickjung

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 }

kendrickjung avatar Feb 19 '21 13:02 kendrickjung

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)

ghost avatar Feb 21 '21 09:02 ghost