Example #1
0
 /**
  * 返回 domain 指定的哈希key值总数
  *
  * @param domain
  * @return
  */
 public long lenHset(String domain) {
   ShardedJedis shardedJedis = null;
   long retList = 0;
   try {
     shardedJedis = slaveShardedJedisPool.getResource();
     retList = shardedJedis.hlen(domain);
   } catch (Exception ex) {
     logger.error("hkeys error.", ex);
   } finally {
     returnResource(shardedJedis);
   }
   return retList;
 }
 /**
  * 通过key返回field的数量
  *
  * @param key
  * @return
  */
 public Long hlen(String key) {
   ShardedJedis jedis = null;
   Long res = null;
   try {
     jedis = pool.getResource();
     res = jedis.hlen(key);
   } catch (Exception e) {
     pool.returnBrokenResource(jedis);
     e.printStackTrace();
   } finally {
     returnResource(pool, jedis);
   }
   return res;
 }