mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
7
cache/dynacache/dynacache.go
vendored
7
cache/dynacache/dynacache.go
vendored
@@ -120,6 +120,7 @@ func (o OptionsPartition) CalculateMaxSize(maxSizePerPartition int) int {
|
||||
// A dynamic partitioned cache.
|
||||
type Cache struct {
|
||||
mu sync.RWMutex
|
||||
resizeMu sync.Mutex
|
||||
|
||||
partitions map[string]PartitionManager
|
||||
|
||||
@@ -231,6 +232,12 @@ func (c *Cache) Stop() {
|
||||
}
|
||||
|
||||
func (c *Cache) adjustCurrentMaxSize() {
|
||||
if !c.resizeMu.TryLock() {
|
||||
// Prevent multiple concurrent resizes.
|
||||
return
|
||||
}
|
||||
defer c.resizeMu.Unlock()
|
||||
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
|
Reference in New Issue
Block a user