nictuku/dht

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

kendrickjung opened this issue · 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
}

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
}

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)