From 4e3cf9404b08dcccc65927acbb03d8573b370972 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Fri, 20 Oct 2023 18:19:51 -0400 Subject: [PATCH 1/2] Adding keysExist to Using StorageEngines documentation --- .../Articles/Fundamentals/Using StorageEngines.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Bodega/Documentation.docc/Articles/Fundamentals/Using StorageEngines.md b/Sources/Bodega/Documentation.docc/Articles/Fundamentals/Using StorageEngines.md index 01bc0dd..a4792e7 100644 --- a/Sources/Bodega/Documentation.docc/Articles/Fundamentals/Using StorageEngines.md +++ b/Sources/Bodega/Documentation.docc/Articles/Fundamentals/Using StorageEngines.md @@ -28,6 +28,7 @@ public protocol StorageEngine: Actor { func removeAllData() async throws func keyExists(_ key: CacheKey) async -> Bool + func keysExist(_ keys: [CacheKey]) async -> [CacheKey] func keyCount() async -> Int func allKeys() async -> [CacheKey] From 342790d92153d96d9a548546018db537d0524f70 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Fri, 20 Oct 2023 18:19:58 -0400 Subject: [PATCH 2/2] Spring cleaning --- Sources/Bodega/DiskStorageEngine.swift | 3 ++- Sources/Bodega/ObjectStorage.swift | 3 ++- Sources/Bodega/StorageEngine.swift | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Bodega/DiskStorageEngine.swift b/Sources/Bodega/DiskStorageEngine.swift index f9b22ef..cf93d10 100644 --- a/Sources/Bodega/DiskStorageEngine.swift +++ b/Sources/Bodega/DiskStorageEngine.swift @@ -75,7 +75,8 @@ public actor DiskStorageEngine: StorageEngine { return zip( keys, await self.read(keys: keys) - ).map { ($0, $1) } + ) + .map({ ($0, $1) }) } /// Reads all the `[Data]` located in the `directory`. diff --git a/Sources/Bodega/ObjectStorage.swift b/Sources/Bodega/ObjectStorage.swift index 0fbc362..d9a2c91 100644 --- a/Sources/Bodega/ObjectStorage.swift +++ b/Sources/Bodega/ObjectStorage.swift @@ -87,7 +87,8 @@ public actor ObjectStorage { return zip( keys, await self.objects(forKeys: keys) - ).map { ($0, $1) } + ) + .map({ ($0, $1) }) } /// Reads all `[Object]` objects. diff --git a/Sources/Bodega/StorageEngine.swift b/Sources/Bodega/StorageEngine.swift index f3a39f7..c54d9e2 100644 --- a/Sources/Bodega/StorageEngine.swift +++ b/Sources/Bodega/StorageEngine.swift @@ -101,7 +101,7 @@ extension StorageEngine { public func keysExist(_ keys: [CacheKey]) async -> [CacheKey] { let allKeys = await self.allKeys() let keySet = Set(allKeys) - return keys.filter { keySet.contains($0) } + return keys.filter({ keySet.contains($0) }) } /// Read the number of keys located in the ``StorageEngine``.