/** * 获取Set * * @param key * @return */ public Set<String> getSet(String key) { ShardedJedis shardedJedis = null; try { shardedJedis = slaveShardedJedisPool.getResource(); return shardedJedis.smembers(key); } catch (Exception ex) { logger.error("getList error.", ex); } finally { returnResource(shardedJedis); } return null; }
/** * 通过key获取set中所有的value * * @param key * @return */ public Set<String> smembers(String key) { ShardedJedis jedis = null; Set<String> res = null; try { jedis = pool.getResource(); res = jedis.smembers(key); } catch (Exception e) { pool.returnBrokenResource(jedis); e.printStackTrace(); } finally { returnResource(pool, jedis); } return res; }
public Set<String> sMember(String key) throws Exception { Set<String> members = null; ShardedJedis jedis = null; try { jedis = jedisPool.getResource(); members = jedis.smembers(key); } catch (Exception e) { throw e; } finally { if (jedis != null) { jedisPool.returnResource(jedis); } } return members; }