Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Full Identity Map that has relationships to objects cached in weaker types

Thanks Jason, thanks Gordon.

Ok, this could be a problem. I want to make an example:

I have an entity User that has a one-to-many relationship to Message (User
(1) -> Message (N)). I have to cache all Users, but I do not want to cache
all Messages. 

Let´s say I have 100.000 users and every user has about 100 messages. As I
said, I want to cache all Users but only a few messages (let´s say about
10.000). Now I can think of two approaches.

a) I cache all Users by using a Full Identity Map. Messages are cached by
using a Weak Identity Map. The problem is that Messages will never be
garbage collected (unless they are deleted), because they are hard
referenced by the User. This will lead to extreme memory consumption (and
Out-Of-Memory-Errors).

b) I cache all Users by using a Soft Cache Weak Identity Map. Messages are
cached by using a Weak Identity Map. I doubt a Soft Cache Weak Identity Map
is still performant when its size is very large (100.000). This is because
it is implemented as a LinkedList and every look up of an entity will cost
O(n). This leads to another very important question. What should be the
maximum size of a Soft Cache Weak Identity Map so that it still performs
well?

I wonder what would be the best solution in this case.
-- 
View this message in context: http://www.nabble.com/Full-Identity-Map-that-has-relationships-to-objects-cached-in-weaker-types-tp21188540p21193184.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top