4 Replies Latest reply on Dec 28, 2012 9:51 AM by Gregor Kovač

    Maintaining insertion order

    Gregor Kovač Newbie

      Hi!

       

      I'm using Infinispan 5.0.1. and I want that I get values from the cache in the same order as I put them in.

      For example:

      Cache<String, String> myCache = defaultCacheManager.getCache("myCache");
      myCache.put("1", "ONE");
      myCache.put("2", "TWO");
      myCache.put("3", "THREE");
      myCache.keySet();
      Set<String> keySet = myCache.keySet();
      for (String key : keySet) {
          System.out.println(myCache.get(key));
      }

       

      This should print out:

      ONE

      TWO

      THREE

       

      Similar to LinkedHashMap in Java. How do I do it?

       

      Best regards,

          Kovi