|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | | -/// Specifies the cache configuration for a Firebase Data Connect instance |
| 15 | +/// Specifies the cache configuration for a `DataConnect` instance. |
| 16 | +/// |
| 17 | +/// You can configure the cache's storage policy and its maximum size. |
16 | 18 | @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) |
17 | 19 | public struct CacheSettings: Sendable { |
| 20 | + /// Defines the storage mechanism for the cache. |
18 | 21 | public enum Storage: Sendable { |
| 22 | + /// The cache will be written to disk, persisting data across application launches. |
19 | 23 | case persistent |
| 24 | + /// The cache will only be stored in memory and will be cleared when the application terminates. |
20 | 25 | case memory |
21 | 26 | } |
22 | 27 |
|
23 | | - public let storage: Storage // default provider is persistent type |
| 28 | + /// The storage mechanism to be used for caching. The default is `.persistent`. |
| 29 | + public let storage: Storage |
| 30 | + /// The maximum size of the cache in bytes. |
| 31 | + /// |
| 32 | + /// This size is not strictly enforced but is used as a guideline by the cache |
| 33 | + /// to trigger cleanup procedures. The default is 100MB (100,000,000 bytes). |
24 | 34 | public let maxSizeBytes: UInt64 |
25 | 35 |
|
| 36 | + /// Creates a new cache settings configuration. |
| 37 | + /// |
| 38 | + /// - Parameters: |
| 39 | + /// - storage: The storage mechanism to use. Defaults to `.persistent`. |
| 40 | + /// - maxSize: The maximum desired size of the cache in bytes. Defaults to 100MB. |
26 | 41 | public init(storage: Storage = .persistent, maxSize: UInt64 = 100_000_000) { |
27 | 42 | self.storage = storage |
28 | 43 | maxSizeBytes = maxSize |
|
0 commit comments