Wednesday, 15 February 2012

java - How to efficiently store objects in a LoadingCache, that may have more than one key -



java - How to efficiently store objects in a LoadingCache, that may have more than one key -

i have info construction have objects, , have targets. , have many many relationship. eg: object1 has targets: t1, t2, t3 , object2 has targets: t2, t3.

i want write guava loadingcache in order store each of these objects target. now, problem is: objects 1 , 2 both stored under t2, , t3. , wastage.

so, 1 solution thought of have map of ids. , in target cache, i'll store object id.

now, question is: since in loadingcache dont have methods exposed take care of clearing cache(or way hear when cache gets cleared.), have no way of keeping id map upto date, when cache gets updated.

is there way of keeping these 2 maps in sync?

i question premises, "this wastage." you're storing multiple references objects, not multiple copies of objects themselves, , references cheap. having map of ids strictly more expensive original approach in first place.

java caching guava

No comments:

Post a Comment