shad-go/lrucache/cache.go

23 lines
614 B
Go
Raw Permalink Normal View History

2022-02-10 22:06:57 +00:00
//go:build !change
package lrucache
type Cache interface {
// Get returns value associated with the key.
//
// The second value is a bool that is true if the key exists in the cache,
// and false if not.
Get(key int) (int, bool)
// Set updates value associated with the key.
//
// If there is no key in the cache new (key, value) pair is created.
Set(key, value int)
// Range calls function f on all elements of the cache
// in increasing access time order.
//
// Stops earlier if f returns false.
Range(f func(key, value int) bool)
// Clear removes all keys and values from the cache.
Clear()
}