1 Reply Latest reply on Feb 25, 2013 11:50 AM by mircea.markus

    Efficient way extract an (any) entry from the cache

    paolodt

      Dear all,

       

      I have a use case for which I need to implement a distributed set, so I was thinking just to use a distributed Cache in which each entry would map to a set entry .

       

      The problem is that I should be able to extract an entry from the set without using its key, let's say the getFirst (but it is not required to maintain the entries ordered).

       

       

      The first solution would be something like this:

       

      map.entrySet().iterator().next()

       

       

      But the documentation states clearly that the methods entrySet(), keySet() and values() should not be used in production.

       

      Is there any efficient or suggested alternative to implement it ? Using a L1 cache ?

       

       

      Cheers,

      Paolo