Ejemplo n.º 1
0
 /**
  * 通过key判断value是否是set中的元素
  *
  * @param key
  * @param member
  * @return
  */
 public Boolean sismember(String key, String member) {
   ShardedJedis jedis = null;
   Boolean res = null;
   try {
     jedis = pool.getResource();
     res = jedis.sismember(key, member);
   } catch (Exception e) {
     pool.returnBrokenResource(jedis);
     e.printStackTrace();
   } finally {
     returnResource(pool, jedis);
   }
   return res;
 }
Ejemplo n.º 2
0
 public boolean sIsMember(String key, String member) throws Exception {
   boolean isMember = false;
   ShardedJedis jedis = null;
   try {
     jedis = jedisPool.getResource();
     isMember = jedis.sismember(key, member);
   } catch (Exception e) {
     throw e;
   } finally {
     if (jedis != null) {
       jedisPool.returnResource(jedis);
     }
   }
   return isMember;
 }
Ejemplo n.º 3
0
 /**
  * @param key
  * @param value
  * @return 判断值是否包含在set中
  */
 public boolean containsInSet(String key, String value) {
   if (key == null || value == null) {
     return false;
   }
   ShardedJedis shardedJedis = null;
   try {
     shardedJedis = slaveShardedJedisPool.getResource();
     return shardedJedis.sismember(key, value);
   } catch (Exception ex) {
     logger.error("setList error.", ex);
   } finally {
     returnResource(shardedJedis);
   }
   return false;
 }