hashicorp / golang-lru

Golang LRU cache
Mozilla Public License 2.0
4.32k stars 498 forks source link

ARC and 2Q caches are not compatible with LRUCache interface #95

Closed floatdrop closed 1 year ago

floatdrop commented 2 years ago

Currently building next code:

package main

import (
    "github.com/hashicorp/golang-lru"
    "github.com/hashicorp/golang-lru/simplelru"
)

func main() {
    var cache simplelru.LRUCache
    cache, _ = lru.NewARC(10)
}

Fails as *lru.ARCCache does not implements parts of simplelru.LRUCache:

Is it reasonable to fix these mismatches to comply declared interface?

jefferai commented 1 year ago

It works the other way around; simplelru is used by other implementations (2Q, ARC) so provides an interface to those implementations in case there are different desired implementations of simplelru. Certainly more functions could be added but at the moment the simplelru.LRUCache interface is not intended for end users, instead the interface/capabilities of the various user-facing implementations are for direct use.