|
|
|
@ -484,13 +484,10 @@ func (memory *memoryDriver) expireObjects() { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
var keysToRemove []string |
|
|
|
|
if len(memory.objectMetadata) > 0 { |
|
|
|
|
memory.lock.RLock() |
|
|
|
|
var earliest time.Time |
|
|
|
|
empty := true |
|
|
|
|
for key, object := range memory.objectMetadata { |
|
|
|
|
if empty { |
|
|
|
|
empty = false |
|
|
|
|
} |
|
|
|
|
if time.Now().Add(-memory.expiration).After(object.metadata.Created) { |
|
|
|
|
keysToRemove = append(keysToRemove, key) |
|
|
|
|
} else { |
|
|
|
@ -505,13 +502,12 @@ func (memory *memoryDriver) expireObjects() { |
|
|
|
|
memory.objects.Remove(key) |
|
|
|
|
} |
|
|
|
|
memory.lock.Unlock() |
|
|
|
|
if empty { |
|
|
|
|
time.Sleep(memory.expiration) |
|
|
|
|
} else { |
|
|
|
|
sleepFor := earliest.Sub(time.Now()) |
|
|
|
|
if sleepFor > 0 { |
|
|
|
|
time.Sleep(sleepFor) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
time.Sleep(memory.expiration) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|