-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any way to set expiration policy for cache? #40
Comments
@fudiwei Hey, I see what you are saying. |
@kfiroo Thank you for your response. As far as I know, there isn't an effective mechanism to manage the cache dir in Android OS. |
Thanks for this library! :) So, how does the OS manage the cache? I am thinking of using this in my news app so there are lots of images that will possible be cached. Will it bloat the users device? |
This is what I could find in the android developer docs https://developer.android.com/guide/topics/data/data-storage.html
Looks like the OS would clean this folder in order to free up space but I'm not sure how often. Currently, managing the cache manually feels like a bit too much for this simple component. @chatras If you could find a heuristic by which to clear your cache, or even specific URLs that are not needed anymore this should not be a problem for you. |
Hi I have a similar use-case... basically I'm looking for a way to delete an image from the cache if that image hasn't been accessed in 48 hours. Currently, I'm loading an image like so (testing with a 60 second ttl): However when I iterate over the images in the cache using From my understanding, that However, the other piece is I'd like to basically refresh the expiration time each time we attempt to fetch the image from the cache if that makes sense. So, back to my first sentence, I'm looking for a way to delete an image from the cache if that image hasn't been accessed in 48 hours. |
You mentioned to chatras, "If you could find a heuristic by which to clear your cache, or even specific URLs that are not needed anymore this should not be a problem for you. |
@jasongaare Hey, 1. Removing stale urls from the cache and their corresponding files from the fs.We could add a method in When would you use this method? 2. Using a different cache policy that expires a url that wasn't accessed in some time.This one is a bit more tricky. Let me know if that makes sense or if I can help you in any other way :) |
Thanks for the help - sorry for the delay in response. The main motivation here would be to limit network requests for the same image multiple times. I've had better experience with this library than the built-in caching for React Native. I think implementing my own cache policy will be the way to go, and utilizing |
@jasongaare Great! Please let me know how that works for you and if there is anything I could do to help you! |
Cache means NOT PERSISTENT.
Now, I must record the time when an image been cached, and invoke the delete method over a period of time manually. So, I think it could be better to provide an option to set expiration policy.
The text was updated successfully, but these errors were encountered: