Skip to content

Commit

Permalink
change dump lock range (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
fishyww authored Mar 7, 2023
1 parent 32ec82b commit 93e2a80
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (n *namespaceCache) drain() {
}
}

func (n *namespaceCache) dump(name string) error {
func (n *namespaceCache) cacheDump() map[string]map[string]string {
n.lock.Lock()
defer n.lock.Unlock()

Expand All @@ -48,7 +48,12 @@ func (n *namespaceCache) dump(name string) error {
for namespace, cache := range n.caches {
dumps[namespace] = cache.dump()
}
return dumps
}

func (n *namespaceCache) dump(name string) error {

dumps := n.cacheDump()
tmp := name + "tmp"
f, err := os.OpenFile(tmp, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
Expand Down

0 comments on commit 93e2a80

Please sign in to comment.