public String set(String key, String value) { ShardedJedis jedis = null; boolean success = true; try { pool = getPool(); jedis = pool.getResource(); return jedis.set(key, value); } catch (JedisException e) { success = false; if (jedis != null) { pool.close(); } throw e; } finally { if (success && jedis != null) { pool.close(); } } }
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(); } } }
public Long removeMapField(String key, String... fields) { ShardedJedis jedis = null; boolean success = true; try { pool = getPool(); jedis = pool.getResource(); return jedis.hdel(key, fields); } catch (JedisException e) { success = false; if (jedis != null) { pool.close(); } throw e; } finally { if (success && jedis != null) { pool.close(); } } }
public String get(String key) { String value = null; ShardedJedis jedis = null; try { pool = getPool(); jedis = pool.getResource(); value = jedis.get(key); } catch (Exception e) { e.printStackTrace(); } finally { pool.close(); } return value; }