Comments (8)
Thanks for your patient answer ^_^
from react-native-cached-image.
@gameboyVito Hey
Currently, if you know the urls of the cached images you can use ImageCacheProvider.deleteMultipleCachedImages
, otherwise I will provide a ImageCacheProvider.clearCache
method in the next release.
Regarding getting the cache size, this turned out to be harder then I first thought. I was hoping that using RNFetchBlob.fs.stat
on the root cache dir would be enough, but it doesn't work recursively.
I'm working on a solution that will traverse the cache files and accumulate the size, however it doesn't feel right doing all this work over the RN bridge.
Suggestions are welcome.
Limiting the cache size is a nice concept but I'm afraid implementing it might be a bit of an overhead, for instance, how would handle the case where the cache is "full" and the user tries to cache another image? we would also need to know the cache size at all times, and the sizes of images before we download them. probably manage an LRU or other cache clearing mechanism.
Again, suggestions are welcome :)
from react-native-cached-image.
Yeah, ImageCacheProvider.clearAllCache()
would be nice~ Maybe you can reference on this repo, it implements the LRU algorithm to clear the cache.
from react-native-cached-image.
@gameboyVito I would prefer to keep this component simple for now, and avoid dealing with managing the cache size.
I'm working on a getCacheSize
method that users can use to manage the cache themselves, and maybe implement cache management in the future.
Thanks for the reference! It would be helpful when we would decide to add cache management.
from react-native-cached-image.
@kfiroo Hi, I found this repo has implemented something like lifecycle for cached images. That means when you quit your app and reopen it, all cached images will be deleted when you pass a prop called mutable
. Just like what I asked today, if my user profile photo is changed in the website but the server always return the same url, there is no way to know whether to update the cached image when i am using your component. Though you provides a ImageCacheProvider
to clear the specified image, this is still not enough to detect the difference between two images. If this comparison is too hard to implement, maybe just provide a prop to set the cached images just live in the runtime.
from react-native-cached-image.
@gameboyVito Oh! I see what you're saying.
This is actually not possible to achieve with the current implementation :(
I was under the impression that react-native
has an internal cache system for fetching urls, which means that within a single app session the urls would not get downloaded again (kinda like the browser has it) so I'm not sure the mutable cache system is required.
Maybe for your profile picture you can simply use an Image
component and the image would be downloaded only once.
from react-native-cached-image.
@gameboyVito Hey, master has a version with a working getCacheInfo
that returns the following format
{
files: [], // an array of all files in the cache represented by their `fs.stat()` result
size: 0 // size of cache in bytes (see example)
}
Hope that helps
from react-native-cached-image.
genius! thx~
from react-native-cached-image.
Related Issues (20)
- Not working on the snack.expo.io platform HOT 1
- ImageCachePreloader does not work on first time preloading HOT 2
- The code in example does NOT really clear the cache
- Netinfo error HOT 11
- Open image in modal
- RN 0.60 support HOT 4
- Update TypeScript types to reflect examples. HOT 1
- Change dependency react-native-fetch-blob to rn-fetch-blob as the previous repo has been achieved HOT 2
- componentWillReceiveProps [Deprecated]
- NetInfo is deprecated from react-native use from @community HOT 9
- Replace react-native-fetch-blob with rn-fetch-blob
- Crashes in release on 0.60
- webp support for image?
- netinfo has been removed from react-native HOT 8
- Update Readme HOT 1
- Please remove this issue
- Getting double borders HOT 1
- Error on hermes engine: DocumentDir of null
- separate netinfo from React native & import from react native community
- Import Netinfo from react native community
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-cached-image.