I'm using the LruCache to cache several bitmaps in my Android app. But because I load those bitmaps according to data from more than one datatable from the database. For example: Object A is stored in table A and has an image while object B is stored in table B and has another image.
The ID for object A and B might be the same because they are stored in different tables. Therefore I have also two (or more) LruCache instances which I think is not that good. So I want to store all images in just one LruCache but then I need a key that can handle multiple occurences of the same ID. My guess is writing a key class. Any best practise for that? What about the hash-key?
private LruCache<MyKey, Bitmap> cache;
class MyKey {
private final String className;
private final int key;
public MyKey(Object object, int key) {
className = object.getClass().getCanonicalName();
this.key = key;
}
@Override
public int hashCode() {
// TODO How to implement?
return super.hashCode();
}
}