Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kendrickjung opened this issue Feb 16, 2021 · 2 comments

Comments

@kendrickjung
Copy link

kendrickjung commented Feb 16, 2021

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
Copy link
Author

kendrickjung commented Feb 19, 2021

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
Copy link

ghost commented Feb 21, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant