public void set(final String key, final long serializable) {
   cache.withRunnable(
       new RedisRunnable() {
         @Override
         public void run(Jedis jedis) {
           jedis.hset(id, key, Long.toString(serializable));
         }
       });
 }
 public void remove(final String key) {
   cache.withRunnable(
       new RedisRunnable() {
         @Override
         public void run(Jedis jedis) {
           jedis.hdel(id, key);
         }
       });
 }
 public long size() {
   return cache.withJedisCallable(
       new RedisCallable<Long>() {
         @Override
         public Long call(Jedis jedis) {
           return jedis.hlen(id);
         }
       });
 }
 public void clear() {
   cache.withRunnable(
       new RedisRunnable() {
         @Override
         public void run(Jedis jedis) {
           jedis.del(id);
         }
       });
 }
 public long addAndGet(final String key, final long add) {
   return cache.withJedisCallable(
       new RedisCallable<Long>() {
         @Override
         public Long call(Jedis jedis) {
           return jedis.hincrBy(id, key, add);
         }
       });
 }
 public long[] getAll(final String... keys) {
   return cache.withJedisCallable(
       new RedisCallable<long[]>() {
         @Override
         public long[] call(Jedis jedis) {
           List<String> ret = jedis.hmget(id, keys);
           return toArray(ret);
         }
       });
 }
 public String[] keys() {
   return cache.withJedisCallable(
       new RedisCallable<String[]>() {
         @Override
         public String[] call(Jedis jedis) {
           Set<String> result = jedis.hkeys(id);
           return result.toArray(new String[result.size()]);
         }
       });
 }
 public long[] values() {
   return cache.withJedisCallable(
       new RedisCallable<long[]>() {
         @Override
         public long[] call(Jedis jedis) {
           List<String> result = jedis.hvals(id);
           return toArray(result);
         }
       });
 }
 public void removeAll(final Iterable<String> keys) {
   cache.withRunnable(
       new RedisRunnable() {
         @Override
         public void run(Jedis jedis) {
           Pipeline pipeline = jedis.pipelined();
           for (String s : keys) {
             pipeline.hdel(id, s);
           }
           pipeline.syncAndReturnAll();
         }
       });
 }
 public long get(final String key) {
   return cache.withJedisCallable(
       new RedisCallable<Long>() {
         @Override
         public Long call(Jedis jedis) {
           String v = jedis.hget(id, key);
           if (null == v || 0 == v.length()) {
             return -1L;
           }
           return Long.parseLong(v);
         }
       });
 }
  @SuppressWarnings("unchecked")
  public Set<Map.Entry<String, Long>> entrySet() {
    return cache.withJedisCallable(
        new RedisCallable<Set<Map.Entry<String, Long>>>() {
          @Override
          public Set<Map.Entry<String, Long>> call(Jedis jedis) {
            Set<Map.Entry<String, Long>> result = new HashSet<Map.Entry<String, Long>>();

            for (Map.Entry<String, String> entry : jedis.hgetAll(id).entrySet()) {
              result.add(new Entry(entry.getKey(), entry.getValue()));
            }
            return result;
          }
        });
  }
 public long[] addAndGetAll(final Map<String, Long> values) {
   return cache.withJedisCallable(
       new RedisCallable<long[]>() {
         @Override
         public long[] call(Jedis jedis) {
           Pipeline pipeline = jedis.pipelined();
           for (Map.Entry<String, Long> s : values.entrySet()) {
             pipeline.hincrBy(id, s.getKey(), s.getValue());
           }
           List r = pipeline.syncAndReturnAll();
           long[] result = new long[r.size()];
           int i = 0;
           for (Object o : r) {
             result[i++] = (null == o) ? 0 : (Long) o;
           }
           return result;
         }
       });
 }