You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a use case where the result of fetching is nil.
Now nil means no cache, so when caching an Optional value, there is no distinction between no cache and cached nil .
structR{func fetch()asyncthrows->Data{@Cache(key:"my_optional_data", lifetime:.duration(3600))vardata:Data?
if data ==nil{ // no cache or cached nil?
}}}
I want to extend the following API to support Optional values.
structR{func fetch()asyncthrows->Data{@Cache(key:"my_data", lifetime:.duration(3600))vardata:Data
if data.validCacheExists {return data
}else{letnewData=try?awaitfetchNewData()cache(newData, into: data)return newData
}}}structR{func fetch()asyncthrows->Data{@Cache(key:"my_optional_data", lifetime:.duration(3600))vardata:Data?
if data.validCacheExists {return data
}else{letnewData=try?awaitfetchNewData()cache(newData, into: data)return newData
}}}
This will be a breaking change, so it doesn't have to be implemented exactly as proposed.
But the migration should not be difficult.
The text was updated successfully, but these errors were encountered:
There is a use case where the result of fetching is nil.
Now
nil
means no cache, so when caching anOptional
value, there is no distinction between no cache and cachednil
.I want to extend the following API to support
Optional
values.This will be a breaking change, so it doesn't have to be implemented exactly as proposed.
But the migration should not be difficult.
The text was updated successfully, but these errors were encountered: