예제 #1
0
 /**
  * 通过key向list尾部添加字符串
  *
  * @param key
  * @param strs 可以使一个string 也可以使string数组
  * @return 返回list的value个数
  */
 public Long rpush(String key, String... strs) {
   ShardedJedis jedis = null;
   Long res = null;
   try {
     jedis = pool.getResource();
     res = jedis.rpush(key, strs);
   } catch (Exception e) {
     pool.returnBrokenResource(jedis);
     e.printStackTrace();
   } finally {
     returnResource(pool, jedis);
   }
   return res;
 }
예제 #2
0
 public Long rPush(String listName, String value) {
   ShardedJedis jedis = null;
   boolean success = true;
   try {
     pool = getPool();
     jedis = pool.getResource();
     return jedis.rpush(listName, value);
   } catch (JedisException e) {
     success = false;
     if (jedis != null) {
       pool.close();
     }
     throw e;
   } finally {
     if (success && jedis != null) {
       pool.close();
     }
   }
 }