mirror of
https://github.com/libp2p/go-libp2p-peerstore.git
synced 2024-12-28 23:50:12 +08:00
1b57c62e3d
* benchmark caching and cacheless variants of DS addrbook. * benchmark peers with 1, 10, 100 addrs.
34 lines
805 B
Go
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
|
|
}
|