diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-12-28 16:54:24 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-12-28 16:54:24 +0100 |
commit | 381cb4961eea01e59a15a870f576d582eaa08781 (patch) | |
tree | b39f6dd0a8523ed28eb85d19b2fe83c353270afb | |
parent | ec56e614a438a27e8e611c174c457621a8ec29b1 (diff) |
Return copies of cache values
-rw-r--r-- | cache/cache.go | 6 |
1 files 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 |