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
Currently FileCacheService (the default CacheService implementation provided by core) allows components to cache items with an expiry. The cached item is only deleted when the expired item is requested again. The owner of the cached item is currently responsible for clearing these items from the cache on demand otherwise.
While this solution works, it can be improved to delete the content of the cache that have expired. This is especially useful for handling media/images in push notifications and in-app messages. (Imagine several in app message images being cached bloating the app cache)
Proposal
One possible solution is to run a task to delete all the expired content on every app launch. However, handling cache deletion from an SDK should be done in a way not to impact the app resource usage. In order to achieve a balance the following can be done:
Track the expiry of the cache timestamp with the earliest expiry - scheduledCleanupTimestamp
When FileCacheService is used to cache an item, check if its expiry is earlier than the currently stored scheduledCleanupTimestamp if yes, overwrite it. Otherwise do nothing
On each app launch, check scheduledCleanupTimestamp to see if the cleanup job has to be run and run the job.
Some things to take care of:
Simultaneous access to the cached item (CacheService.get() and delete job happening at once)
Platform and Version
Android 2.x or later.
The text was updated successfully, but these errors were encountered:
Problem
Currently
FileCacheService
(the defaultCacheService
implementation provided by core) allows components to cache items with an expiry. The cached item is only deleted when the expired item is requested again. The owner of the cached item is currently responsible for clearing these items from the cache on demand otherwise.While this solution works, it can be improved to delete the content of the cache that have expired. This is especially useful for handling media/images in push notifications and in-app messages. (Imagine several in app message images being cached bloating the app cache)
Proposal
One possible solution is to run a task to delete all the expired content on every app launch. However, handling cache deletion from an SDK should be done in a way not to impact the app resource usage. In order to achieve a balance the following can be done:
scheduledCleanupTimestamp
FileCacheService
is used to cache an item, check if its expiry is earlier than the currently storedscheduledCleanupTimestamp
if yes, overwrite it. Otherwise do nothingscheduledCleanupTimestamp
to see if the cleanup job has to be run and run the job.Some things to take care of:
Platform and Version
Android 2.x or later.
The text was updated successfully, but these errors were encountered: