Don't lock the cache while adding entries
Entries have their own locking so the cache doesn't need to be lock when adding to them.pull/6186/head
parent
89aeaafd50
commit
87ceb7426a
|
@ -185,10 +185,10 @@ func (c *Cache) WriteMulti(values map[string][]Value) error {
|
|||
}
|
||||
c.mu.RUnlock()
|
||||
|
||||
c.mu.Lock()
|
||||
for k, v := range values {
|
||||
c.write(k, v)
|
||||
c.entry(k).add(v)
|
||||
}
|
||||
c.mu.Lock()
|
||||
c.size = newSize
|
||||
c.mu.Unlock()
|
||||
|
||||
|
@ -416,6 +416,17 @@ func (c *Cache) write(key string, values []Value) {
|
|||
e.add(values)
|
||||
}
|
||||
|
||||
func (c *Cache) entry(key string) *entry {
|
||||
c.mu.Lock()
|
||||
e, ok := c.store[key]
|
||||
if !ok {
|
||||
e = newEntry()
|
||||
c.store[key] = e
|
||||
}
|
||||
c.mu.Unlock()
|
||||
return e
|
||||
}
|
||||
|
||||
// CacheLoader processes a set of WAL segment files, and loads a cache with the data
|
||||
// contained within those files. Processing of the supplied files take place in the
|
||||
// order they exist in the files slice.
|
||||
|
|
Loading…
Reference in New Issue