diff --git a/pkg/registry/generic/registry/storage_factory.go b/pkg/registry/generic/registry/storage_factory.go index f1c265113bf..4a9c845ccc4 100644 --- a/pkg/registry/generic/registry/storage_factory.go +++ b/pkg/registry/generic/registry/storage_factory.go @@ -31,7 +31,24 @@ func StorageWithCacher( resourcePrefix string, scopeStrategy rest.NamespaceScopedStrategy, newListFunc func() runtime.Object) storage.Interface { - return storage.NewCacher( - storageInterface, capacity, etcdstorage.APIObjectVersioner{}, - objectType, resourcePrefix, scopeStrategy, newListFunc) + + config := storage.CacherConfig{ + CacheCapacity: capacity, + Storage: storageInterface, + Versioner: etcdstorage.APIObjectVersioner{}, + Type: objectType, + ResourcePrefix: resourcePrefix, + NewListFunc: newListFunc, + } + if scopeStrategy.NamespaceScoped() { + config.KeyFunc = func(obj runtime.Object) (string, error) { + return storage.NamespaceKeyFunc(resourcePrefix, obj) + } + } else { + config.KeyFunc = func(obj runtime.Object) (string, error) { + return storage.NoNamespaceKeyFunc(resourcePrefix, obj) + } + } + + return storage.NewCacherFromConfig(config) } diff --git a/pkg/storage/cacher.go b/pkg/storage/cacher.go index e8b92f1f1ad..31264cf93bb 100644 --- a/pkg/storage/cacher.go +++ b/pkg/storage/cacher.go @@ -28,7 +28,6 @@ import ( "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/meta" - "k8s.io/kubernetes/pkg/api/rest" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/conversion" @@ -111,37 +110,6 @@ type Cacher struct { stopWg sync.WaitGroup } -// Create a new Cacher responsible from service WATCH and LIST requests from its -// internal cache and updating its cache in the background based on the given -// configuration. -func NewCacher( - storage Interface, - capacity int, - versioner Versioner, - objectType runtime.Object, - resourcePrefix string, - scopeStrategy rest.NamespaceScopedStrategy, - newListFunc func() runtime.Object) Interface { - config := CacherConfig{ - CacheCapacity: capacity, - Storage: storage, - Versioner: versioner, - Type: objectType, - ResourcePrefix: resourcePrefix, - NewListFunc: newListFunc, - } - if scopeStrategy.NamespaceScoped() { - config.KeyFunc = func(obj runtime.Object) (string, error) { - return NamespaceKeyFunc(resourcePrefix, obj) - } - } else { - config.KeyFunc = func(obj runtime.Object) (string, error) { - return NoNamespaceKeyFunc(resourcePrefix, obj) - } - } - return NewCacherFromConfig(config) -} - // Create a new Cacher responsible from service WATCH and LIST requests from its // internal cache and updating its cache in the background based on the given // configuration.