Exemplo n.º 1
0
 public void onStart(Application app) {
   JedisPool p = app.plugin(RedisPlugin.class).jedisPool();
   // uncomment to test sentinel setup
   // JedisSentinelPool p = app.plugin(RedisPlugin.class).jedisSentinelPool();
   Jedis j = p.getResource();
   j.set("foo", "yay");
   p.returnResource(j);
   Cache.set("foo2", 5);
   Map<String, String> m = new HashMap<String, String>();
   m.put("test", "value");
   Cache.set("foo3", m);
 }
Exemplo n.º 2
0
  public static List sortByValue(Map map) {
    List list = new LinkedList(map.entrySet());
    Collections.sort(
        list,
        new Comparator() {
          public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getValue())
                .compareTo(((Map.Entry) (o2)).getValue());
          }
        });

    Map result = new LinkedHashMap();
    for (Iterator it = list.iterator(); it.hasNext(); ) {
      Map.Entry entry = (Map.Entry) it.next();
      result.put(entry.getKey(), entry.getValue());
    }
    Collections.reverse(list);
    return list;
  }