Closed christopherkarani closed 5 months ago
When caching objects
func setupStorage() { do { let memoryConfig = MemoryConfig(expiry: .never) let memoryStorage = MemoryStorage<String, [Lesson]>(config: memoryConfig) let diskConfig = DiskConfig(name: CacheKey.diskConfig, directory: fileUrl()) let diskStorage = try DiskStorage<String, [Lesson]>( config: diskConfig, transformer: TransformerFactory.forCodable(ofType: [Lesson].self) ) let hybridStorage = HybridStorage(memoryStorage: memoryStorage, diskStorage: diskStorage) self.storage = Storage(hybridStorage: hybridStorage) } catch { self.error = AppError.cacheError(description: error.localizedDescription) } }
private func fetchLessons() async { do { let lessons = try await networkService.fetchLessons() self.lessons = lessons cache.insert(lessons, forKey: CacheKey.key) try storage?.setObject(lessons, forKey: CacheKey.key, expiry: .never) let entry = try storage?.entry(forKey: CacheKey.key) print(entry?.filePath) } catch { self.error = AppError.errorFetchingLessons(description: error.localizedDescription) } }
entry?.filePath is always nil
entry?.filePath
let doesExist = storage!.objectExists(forKey: CacheKey.key) always return false when app is closed and open again
let doesExist = storage!.objectExists(forKey: CacheKey.key)
even when I don't manually add the directory to the DiskConfig this still happens
Sorry for not being helpful before, I hope you managed to fix your issue.
Closing, reason outdated issue.
When caching objects
entry?.filePath
is always nillet doesExist = storage!.objectExists(forKey: CacheKey.key)
always return false when app is closed and open againeven when I don't manually add the directory to the DiskConfig this still happens