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