dreymonde/Shallows

Issue with combined cache creation and DiskFolderStorage

Closed this issue · 2 comments

let companySettingsStorage = DiskStorage.main.folder("companysettings.cache", in: .documentDirectory).mapJSONObject(AllCompanySettings.self) let companyCache = MemoryStorage<String, AllCompanySettings>()
let combinedCache = companyCache.combined(with: companySettingsStorage)

I am getting the following error on the combined cache creation. My assumption is the compiler isn't picking up the companySettingsStorage as conforming to StorageProtocol

Generic parameter 'StorageType' could not be inferred

Please advise on the proper creation of a combined cache.

Hi @jasonkruit! I think the problem here is that DiskFolderStorage actually has a Filename keys (which is similar to String, but not String 🙂). So you can:

  1. Create companyCache as MemoryStorage<Filename, AllCompanySettings>
  2. Add .usingStringKeys() to companySettingsStorage

Hope it'll help!

Thank you!