-
Notifications
You must be signed in to change notification settings - Fork 355
Expand file tree
/
Copy pathConfig.swift
More file actions
50 lines (43 loc) · 1.39 KB
/
Config.swift
File metadata and controls
50 lines (43 loc) · 1.39 KB
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
45
46
47
48
49
50
/**
Configuration needed to create a new cache instance
*/
public struct Config {
/// Front cache type
public let frontKind: StorageKind
/// Back cache type
public let backKind: StorageKind
/// 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
/// Maximum size of the cache storage
public let maxSize: UInt
/// Maximum amount of items to store in memory
public let maxObjects: Int
// MARK: - Initialization
/**
Creates a new instance of Config.
- Parameter frontKind: Front cache type
- Parameter backKind: Back cache type
- Parameter expiry: Expiry date that will be applied by default for every added object
- Parameter maxSize: Maximum size of the cache storage
- Parameter maxObjects: Maximum amount of objects to be stored in memory
*/
public init(frontKind: StorageKind, backKind: StorageKind, expiry: Expiry = .never, maxSize: UInt = 0, maxObjects: Int = 0) {
self.frontKind = frontKind
self.backKind = backKind
self.expiry = expiry
self.maxSize = maxSize
self.maxObjects = maxObjects
}
}
// MARK: - Defaults
extension Config {
/**
Default configuration used when config is not specified
*/
public static var defaultConfig: Config {
return Config(
frontKind: .memory,
backKind: .disk)
}
}