diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 418dcdf..cd4d74f 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -5,3 +5,4 @@ code was contributed.) Dustin Sallings Sergey Shepelev +Alan Shreve diff --git a/cache.go b/cache.go index dd8de64..4822116 100644 --- a/cache.go +++ b/cache.go @@ -876,9 +876,10 @@ func (c *cache) Save(w io.Writer) (err error) { } }() c.RLock() - items := c.items - for _, v := range items { + items := make(map[string]*item, len(c.items)) + for k, v := range c.items { gob.Register(v.Object) + items[k] = v } c.RUnlock() err = enc.Encode(&items)