Java Code Examples for redis.clients.jedis.Jedis#hlen()
The following examples show how to use
redis.clients.jedis.Jedis#hlen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JedisUtils.java From fw-spring-cloud with Apache License 2.0 | 6 votes |
/** * <p> * 通过key返回field的数量 * </p> * * @param key * @return */ public Long hlen(String key) { Jedis jedis = null; Long res = null; try { jedis = jedisPool.getResource(); res = jedis.hlen(key); } catch (Exception e) { log.error(e.getMessage()); } finally { returnResource(jedisPool, jedis); } return res; }
Example 2
Source File: RedisServiceImpl.java From ace-cache with Apache License 2.0 | 6 votes |
@Override public Long hlen(String key) { Jedis jedis = null; Long res = null; try { jedis = pool.getResource(); res = jedis.hlen(key); } catch (Exception e) { LOGGER.error(e.getMessage()); } finally { returnResource(pool, jedis); } return res; }
Example 3
Source File: RedisClient.java From apollo with GNU General Public License v2.0 | 6 votes |
public long hLen(String key) throws Exception { Jedis jedis = null; try { jedis = this.jedisPool.getResource(); long ret = jedis.hlen(SafeEncoder.encode(key)); logger.info("hlen key:" + key); return ret; } catch (Exception e) { logger.error(e.getMessage(), e); this.jedisPool.returnBrokenResource(jedis); throw e; } finally { if (jedis != null) { this.jedisPool.returnResource(jedis); } } }
Example 4
Source File: JedisUtil.java From scaffold-cloud with MIT License | 5 votes |
/** * 取得hash的 len * * @param key * @return */ public static Long hlen(final String key) { Jedis jedis = null; Long result = 0L; try { jedis = getResource(); result = jedis.hlen(getBytesKey(key)); } finally { close(jedis); } return result; }
Example 5
Source File: JedisUtil.java From Project with Apache License 2.0 | 5 votes |
/** * 获取hash中存储的个数,类似Map中size方法 * * @param key * @return long 存储的个数 */ public long hlen(String key) { Jedis sjedis = getJedis(); long len = sjedis.hlen(key); sjedis.close(); return len; }
Example 6
Source File: RedisClient.java From Mykit with Apache License 2.0 | 5 votes |
public Long hlen(String key) { Jedis client = jedisPool.getResource(); try { return client.hlen(key); } finally { // 向连接池“归还”资源 jedisPool.returnResourceObject(client); } }
Example 7
Source File: RedisHashRecordReader.java From Redis-4.x-Cookbook with MIT License | 5 votes |
public void initialize(InputSplit split, TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException { host = split.getLocations()[0]; prefix = ((RedisHashInputSplit) split).getPrefix(); key = ((RedisHashInputSplit) split).getKey(); String hashKey = prefix+":"+key; jedis = new Jedis(host); log.info("Connect to " + host); jedis.connect(); jedis.getClient().setTimeoutInfinite(); totalKVs = jedis.hlen(hashKey); keyValueMapIter = jedis.hgetAll(hashKey).entrySet().iterator(); }
Example 8
Source File: JedisForbiddenQueueStore.java From vscrawler with Apache License 2.0 | 5 votes |
@Override public long size(String queueID) { Jedis jedis = jedisPool.getResource(); try { return jedis.hlen(makeDataKey(queueID)); } finally { IOUtils.closeQuietly(jedis); } }
Example 9
Source File: JedisScoredQueueStore.java From vscrawler with Apache License 2.0 | 5 votes |
@Override public long size(String queueID) { Jedis jedis = jedisPool.getResource(); try { return jedis.hlen(makeDataKey(queueID)); } finally { IOUtils.closeQuietly(jedis); } }
Example 10
Source File: JedisUtil.java From BigData with GNU General Public License v3.0 | 5 votes |
/** * 获取hash中存储的个数,类似Map中size方法 * * @param String * key * @return long 存储的个数 * */ public long hlen(String key) { // ShardedJedis sjedis = getShardedJedis(); Jedis sjedis = getJedis(); long len = sjedis.hlen(key); returnJedis(sjedis); return len; }
Example 11
Source File: JedisSegmentScoredQueueStore.java From vscrawler with Apache License 2.0 | 4 votes |
@Override public long size(String queueID) { @Cleanup Jedis jedis = jedisPool.getResource(); return jedis.hlen(makeDataKey(queueID)); }
Example 12
Source File: DefaultRedis.java From craft-atom with MIT License | 4 votes |
private Long hlen0(Jedis j, String key) { return j.hlen(key); }