go-libp2p-peerstore/pstoreds/cache.go
Raúl Kripalani 1b57c62e3d increase benchmark coverage; introduce config struct.
* benchmark caching and cacheless variants of DS addrbook.
* benchmark peers with 1, 10, 100 addrs.
2018-09-07 17:45:29 +01:00

34 lines
805 B
Go

package pstoreds
// cache abstracts all methods we access from ARCCache, to enable alternate
// implementations such as a no-op one.
type cache interface {
Get(key interface{}) (value interface{}, ok bool)
Add(key, value interface{})
Remove(key interface{})
Contains(key interface{}) bool
Peek(key interface{}) (value interface{}, ok bool)
}
// noopCache is a dummy implementation that's used when the cache is disabled.
type noopCache struct {
}
func (*noopCache) Get(key interface{}) (value interface{}, ok bool) {
return nil, false
}
func (*noopCache) Add(key, value interface{}) {
}
func (*noopCache) Remove(key interface{}) {
}
func (*noopCache) Contains(key interface{}) bool {
return false
}
func (*noopCache) Peek(key interface{}) (value interface{}, ok bool) {
return nil, false
}