MemoryConfig.swift 773 B

123456789101112131415161718192021
  1. import Foundation
  2. public struct MemoryConfig {
  3. /// Expiry date that will be applied by default for every added object
  4. /// if it's not overridden in the add(key: object: expiry: completion:) method
  5. public let expiry: Expiry
  6. /// The maximum number of objects in memory the cache should hold.
  7. /// If 0, there is no count limit. The default value is 0.
  8. public let countLimit: UInt
  9. /// The maximum total cost that the cache can hold before it starts evicting objects.
  10. /// If 0, there is no total cost limit. The default value is 0
  11. public let totalCostLimit: UInt
  12. public init(expiry: Expiry = .never, countLimit: UInt = 0, totalCostLimit: UInt = 0) {
  13. self.expiry = expiry
  14. self.countLimit = countLimit
  15. self.totalCostLimit = totalCostLimit
  16. }
  17. }