From 64585cf823c1b57f8c98505a2ae124a23ff83dc5 Mon Sep 17 00:00:00 2001 From: weilaaa Date: Wed, 22 Jun 2022 11:26:07 +0800 Subject: [PATCH] correct input params and add godoc Kubernetes-commit: 9847b2eeb43e3fd13581dfdb4eeb288139ea7f3b --- tools/cache/index.go | 2 +- tools/cache/store.go | 13 +++++++++---- tools/cache/thread_safe_store.go | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/cache/index.go b/tools/cache/index.go index 1d6aae56..c6af49d8 100644 --- a/tools/cache/index.go +++ b/tools/cache/index.go @@ -47,7 +47,7 @@ type Indexer interface { // ByIndex returns the stored objects whose set of indexed values // for the named index includes the given indexed value ByIndex(indexName, indexedValue string) ([]interface{}, error) - // GetIndexer return the indexers + // GetIndexers return the indexers GetIndexers() Indexers // AddIndexers adds more indexers to this store. If you call this after you already have data diff --git a/tools/cache/store.go b/tools/cache/store.go index 24ffabab..5308ea74 100644 --- a/tools/cache/store.go +++ b/tools/cache/store.go @@ -199,8 +199,11 @@ func (c *cache) Index(indexName string, obj interface{}) ([]interface{}, error) return c.cacheStorage.Index(indexName, obj) } -func (c *cache) IndexKeys(indexName, indexKey string) ([]string, error) { - return c.cacheStorage.IndexKeys(indexName, indexKey) +// IndexKeys returns the storage keys of the stored objects whose set of +// indexed values for the named index includes the given indexed value. +// The returned keys are suitable to pass to GetByKey(). +func (c *cache) IndexKeys(indexName, indexedValue string) ([]string, error) { + return c.cacheStorage.IndexKeys(indexName, indexedValue) } // ListIndexFuncValues returns the list of generated values of an Index func @@ -208,8 +211,10 @@ func (c *cache) ListIndexFuncValues(indexName string) []string { return c.cacheStorage.ListIndexFuncValues(indexName) } -func (c *cache) ByIndex(indexName, indexKey string) ([]interface{}, error) { - return c.cacheStorage.ByIndex(indexName, indexKey) +// ByIndex returns the stored objects whose set of indexed values +// for the named index includes the given indexed value. +func (c *cache) ByIndex(indexName, indexedValue string) ([]interface{}, error) { + return c.cacheStorage.ByIndex(indexName, indexedValue) } func (c *cache) AddIndexers(newIndexers Indexers) error { diff --git a/tools/cache/thread_safe_store.go b/tools/cache/thread_safe_store.go index 6d58c0d6..1182ea14 100644 --- a/tools/cache/thread_safe_store.go +++ b/tools/cache/thread_safe_store.go @@ -47,9 +47,9 @@ type ThreadSafeStore interface { ListKeys() []string Replace(map[string]interface{}, string) Index(indexName string, obj interface{}) ([]interface{}, error) - IndexKeys(indexName, indexKey string) ([]string, error) + IndexKeys(indexName, indexedValue string) ([]string, error) ListIndexFuncValues(name string) []string - ByIndex(indexName, indexKey string) ([]interface{}, error) + ByIndex(indexName, indexedValue string) ([]interface{}, error) GetIndexers() Indexers // AddIndexers adds more indexers to this store. If you call this after you already have data