diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 8a4da4e..355fb41 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,3 +6,4 @@ code was contributed.) Dustin Sallings Jason Mooberry Sergey Shepelev +Christoph Petrausch \ No newline at end of file diff --git a/cache.go b/cache.go index 51b32d6..70e4dad 100644 --- a/cache.go +++ b/cache.go @@ -1022,22 +1022,6 @@ func (c *cache) Items() map[string]Item { return m } -// Returns all not expired items in the cache. This method is save to use with -// an active janitor since it copies the underlying map. Therefore method is -// costly in terms of time and memory. You can read while using this method but -// not write. Use with caution. -func (c *cache) GetNotExpiredItems() map[string]Item { - retMap := make(map[string]Item, c.ItemCount()) - c.mu.RLock() - for key, item := range c.items{ - if !item.Expired() { - retMap[key] = item - } - } - c.mu.RUnlock() - return retMap -} - // Returns the number of items in the cache. This may include items that have // expired, but have not yet been cleaned up. func (c *cache) ItemCount() int { diff --git a/cache_test.go b/cache_test.go index a2e7981..6ff361b 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1254,7 +1254,7 @@ func TestCacheGetAllNotExpiredItems(t *testing.T) { tc.Set("b", "b", DefaultExpiration) tc.Set("c", "c", time.Millisecond*1) time.Sleep(time.Millisecond*2) - allNotExpiredItems := tc.GetNotExpiredItems() + allNotExpiredItems := tc.Items() if len(allNotExpiredItems) != 2 { t.Error("There are more or less items in the result than the two unexpired.") } @@ -1710,7 +1710,7 @@ func BenchmarkGetAllNotExpiredItems(b *testing.B) { } b.ResetTimer() for j:= 0; j < b.N; j++{ - tc.GetNotExpiredItems() + tc.Items() } }) }