ソースを参照

Fix ineffective configuration parameter in DiskStorage

invalidate previous timer and start a new one upon new configuration.
Erinç Olkan Dokumacıoğlu 10 ヶ月 前
コミット
fc1d2c69c8
1 ファイル変更5 行追加0 行削除
  1. 5 0
      Sources/Cache/MemoryStorage.swift

+ 5 - 0
Sources/Cache/MemoryStorage.swift

@@ -75,6 +75,11 @@ public enum MemoryStorage {
             didSet {
             didSet {
                 storage.totalCostLimit = config.totalCostLimit
                 storage.totalCostLimit = config.totalCostLimit
                 storage.countLimit = config.countLimit
                 storage.countLimit = config.countLimit
+                cleanTimer?.invalidate()
+                cleanTimer = .scheduledTimer(withTimeInterval: config.cleanInterval, repeats: true) { [weak self] _ in
+                    guard let self = self else { return }
+                    self.removeExpired()
+                }
             }
             }
         }
         }