Applet Image Cache
I have an applet that shows a couple o开发者_Python百科f images. A lot (10-20) of these images is identical, and is fetched from the internet in a non-parallel way. Is there an imagecache that I can use? So I only fetch the same image once, or do I have to make my own?
Thanks
Much depends on your needs, but I'm guessing you want a minimal footprint in an Applet. This very simple example uses a List
implementation to cache images by index. To ease making the list circular, the same index is used in a parallel list of names. In your case, a suitable Map<String, Image>
implementation might be simpler. If memory is tight, LinkedHashMap
can be used as a Simple (LRU) Cache in Java.
精彩评论