-
Notifications
You must be signed in to change notification settings - Fork 354
Expand file tree
/
Copy pathMemoryConfig.swift
More file actions
27 lines (20 loc) · 1.02 KB
/
MemoryConfig.swift
File metadata and controls
27 lines (20 loc) · 1.02 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
import Foundation
public struct MemoryConfig {
/// 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
/// The maximum number of objects in memory the cache should hold.
/// If 0, there is no count limit. The default value is 0.
public let countLimit: UInt
/// The maximum total cost that the cache can hold before it starts evicting objects.
/// If 0, there is no total cost limit. The default value is 0
public let totalCostLimit: UInt
public init(expiry: Expiry = .never, expirationMode: ExpirationMode = .auto, countLimit: UInt = 0, totalCostLimit: UInt = 0) {
self.expiry = expiry
self.expirationMode = expirationMode
self.countLimit = countLimit
self.totalCostLimit = totalCostLimit
}
}