示例#1
0
 /**
  * 从set中删除value
  *
  * @param key
  * @return
  */
 public boolean removeSetValue(String key, String... value) {
   ShardedJedis shardedJedis = null;
   try {
     shardedJedis = masterShardedJedisPool.getResource();
     shardedJedis.srem(key, value);
     return true;
   } catch (Exception ex) {
     logger.error("getList error.", ex);
   } finally {
     returnResource(shardedJedis);
   }
   return false;
 }
 /**
  * 通过key删除set中对应的value值
  *
  * @param key
  * @param members 可以是一个String 也可以是一个String数组
  * @return 删除的个数
  */
 public Long srem(String key, String... members) {
   ShardedJedis jedis = null;
   Long res = null;
   try {
     jedis = pool.getResource();
     res = jedis.srem(key, members);
   } catch (Exception e) {
     pool.returnBrokenResource(jedis);
     e.printStackTrace();
   } finally {
     returnResource(pool, jedis);
   }
   return res;
 }
 public long sRem(String key, String... members) throws Exception {
   long addCount = 0;
   ShardedJedis jedis = null;
   try {
     jedis = jedisPool.getResource();
     addCount = jedis.srem(key, members);
   } catch (Exception e) {
     throw e;
   } finally {
     if (jedis != null) {
       jedisPool.returnResource(jedis);
     }
   }
   return addCount;
 }