From 381cb4961eea01e59a15a870f576d582eaa08781 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Sat, 28 Dec 2019 16:54:24 +0100 Subject: Return copies of cache values --- cache/cache.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index 7dc654f..e1d540a 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -121,8 +121,8 @@ func (c *Cache) getValue(k uint64) (*Value, bool) { } // List returns the n most recent values in cache c. -func (c *Cache) List(n int) []*Value { - values := make([]*Value, 0, n) +func (c *Cache) List(n int) []Value { + values := make([]Value, 0, n) c.mu.RLock() for i := len(c.keys) - 1; i >= 0; i-- { if len(values) == n { @@ -132,7 +132,7 @@ func (c *Cache) List(n int) []*Value { if !ok { continue } - values = append(values, v) + values = append(values, *v) } c.mu.RUnlock() return values -- cgit v1.2.3