Don't keep the read lock after traversing the items map (before saving to the io.Writer) in Save
This commit is contained in:
parent
5388b25b3b
commit
3986bff69b
7
cache.go
7
cache.go
|
@ -876,11 +876,12 @@ func (c *cache) Save(w io.Writer) (err error) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
items := c.items
|
||||||
for _, v := range c.items {
|
for _, v := range items {
|
||||||
gob.Register(v.Object)
|
gob.Register(v.Object)
|
||||||
}
|
}
|
||||||
err = enc.Encode(&c.items)
|
c.RUnlock()
|
||||||
|
err = enc.Encode(&items)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue