Open levibostian opened 4 years ago
I encountered a use case today for this.
I wrote some migration code in my app where I needed to delete the old Teller cache data of 1 of my repositories so when the app installs the new update, just that 1 cache gets re-created.
I propose adding a clear()
function to the Repository
class that will (1) call deleteOldCache()
on the data source to delete all of the old cache and (2) delete the Teller metadata associated with that repo.
After using Teller a while, there is the potential to have lots of caches saved to the local device.
As an example, you have a
DataSource
that retrieves the user profile of a user's social media account. If you simply callsaveCache()
for every retrieval of every social media account, you could end up retrieving an infinite amount of cache. Teller at this does not provide a convenient way to delete cache that is obsolete. It's a manual process at this time.Proposal: Teller tells your app what cache is (1) a certain age old or (2) the oldest of the cache collection so that you can delete your cache, easily.
Proposed API:
You can specify neither, both, or one of the
obsoleteAgeOfCache
ornumberOfCacheResultsToKeep
properties. Teller will calldeleteOldCache()
with requirements that meets at least 1 of the criteria.deleteOldCache()
does not allow throwing so it's recommended that a delete call error is recorded manually by the developer. Also, if the optional functiondeleteOldCache()
is not defined in the DataSource, Teller will skip the delete request and will be called again the next time theDataSource
is initialized.