/** * 通过key从list尾部删除一个value,并返回该元素 * * @param key * @return */ public String rpop(String key) { ShardedJedis jedis = null; String res = null; try { jedis = pool.getResource(); res = jedis.rpop(key); } catch (Exception e) { pool.returnBrokenResource(jedis); e.printStackTrace(); } finally { returnResource(pool, jedis); } return res; }
public String rPop(String listName) { ShardedJedis jedis = null; boolean success = true; try { pool = getPool(); jedis = pool.getResource(); return jedis.rpop(listName); } catch (JedisException e) { success = false; if (jedis != null) { pool.close(); } throw e; } finally { if (success && jedis != null) { pool.close(); } } }