Question

Say I have a List<List<someObject>> someList {{A,B},{C,D}}. 'A' being the first element and 'B' being the second element in the first list element and so on. Using ehcache, I stored the List<List<someObject>> someList in the ehcache with some key.

During retrieval, does ehcache guarantee the order in which the list is retrieved i.e {{B,A},{D,C}} is possible?? or it will always be {{A,B},{C,D}}.

Note: The order of the outside list is maintained...but the order of the inner lists is reversed

ehcache internal implementation doc any??

Was it helpful?

Solution

You're asking about a property of the List, and a decent List implementation will maintain the order of the elements even after serialization. That's not a problem for ehcache or any other third party library.

Note that ehcache usually stores the cache data in RAM. In case it lacks enough RAM space, it may flush the data into disk (previous configuration).

So, looks like you're retrieving the list and reversing it. Note that you're working with the exact same object reference, so even if you don't store it back into ehcache, the state of the List is still affected.

More info:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top