DiskConfig.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import Foundation
  2. public struct DiskConfig {
  3. /// The name of disk storage, this will be used as folder name within directory
  4. public let name: String
  5. /// Expiry date that will be applied by default for every added object
  6. /// if it's not overridden in the add(key: object: expiry: completion:) method
  7. public let expiry: Expiry
  8. /// Maximum size of the disk cache storage (in bytes)
  9. public let maxSize: UInt
  10. /// A folder to store the disk cache contents. Defaults to a prefixed directory in Caches if nil
  11. public let directory: URL?
  12. #if os(iOS) || os(tvOS)
  13. /// Data protection is used to store files in an encrypted format on disk and to decrypt them on demand.
  14. /// Support only on iOS and tvOS.
  15. public let protectionType: FileProtectionType?
  16. public init(name: String, expiry: Expiry = .never,
  17. maxSize: UInt = 0, directory: URL? = nil,
  18. protectionType: FileProtectionType? = nil) {
  19. self.name = name
  20. self.expiry = expiry
  21. self.maxSize = maxSize
  22. self.directory = directory
  23. self.protectionType = protectionType
  24. }
  25. #else
  26. public init(name: String, expiry: Expiry = .never,
  27. maxSize: UInt = 0, directory: URL? = nil) {
  28. self.name = name
  29. self.expiry = expiry
  30. self.maxSize = maxSize
  31. self.directory = directory
  32. }
  33. #endif
  34. }