From 308bb89e435c4238f791113e92711a8988220841 Mon Sep 17 00:00:00 2001 From: yingtao Date: Fri, 4 May 2018 10:08:36 -0400 Subject: [PATCH] Removed totalCostLimit from MemoryConfig --- .../playground.xcworkspace/contents.xcworkspacedata | 3 +++ Source/Shared/Configuration/MemoryConfig.swift | 13 +++++++++---- Source/Shared/Storage/MemoryStorage.swift | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Playgrounds/Storage.playground/playground.xcworkspace/contents.xcworkspacedata b/Playgrounds/Storage.playground/playground.xcworkspace/contents.xcworkspacedata index 94b2795e..919434a6 100644 --- a/Playgrounds/Storage.playground/playground.xcworkspace/contents.xcworkspacedata +++ b/Playgrounds/Storage.playground/playground.xcworkspace/contents.xcworkspacedata @@ -1,4 +1,7 @@ + + diff --git a/Source/Shared/Configuration/MemoryConfig.swift b/Source/Shared/Configuration/MemoryConfig.swift index fedf6d88..62bdfbdb 100644 --- a/Source/Shared/Configuration/MemoryConfig.swift +++ b/Source/Shared/Configuration/MemoryConfig.swift @@ -6,12 +6,17 @@ public struct MemoryConfig { public let expiry: Expiry /// The maximum number of objects in memory the cache should hold. 0 means no limit. public let countLimit: UInt - /// The maximum total cost that the cache can hold before it starts evicting objects. 0 means no limit. - public let totalCostLimit: UInt - public init(expiry: Expiry = .never, countLimit: UInt = 0, totalCostLimit: UInt = 0) { + public init(expiry: Expiry = .never, countLimit: UInt = 0) { self.expiry = expiry self.countLimit = countLimit - self.totalCostLimit = totalCostLimit + } + + // MARK: - Deprecated + @available(*, deprecated, + message: "Use init(expiry:countLimit:) instead.", + renamed: "init(expiry:countLimit:)") + public init(expiry: Expiry = .never, countLimit: UInt = 0, totalCostLimit: UInt = 0) { + self.init(expiry: expiry, countLimit: countLimit) } } diff --git a/Source/Shared/Storage/MemoryStorage.swift b/Source/Shared/Storage/MemoryStorage.swift index c72cfd30..bb481389 100644 --- a/Source/Shared/Storage/MemoryStorage.swift +++ b/Source/Shared/Storage/MemoryStorage.swift @@ -14,7 +14,6 @@ final class MemoryStorage { init(config: MemoryConfig) { self.config = config self.cache.countLimit = Int(config.countLimit) - self.cache.totalCostLimit = Int(config.totalCostLimit) } }