Java Code Examples for redis.clients.jedis.ShardedJedis#del()
The following examples show how to use
redis.clients.jedis.ShardedJedis#del() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarsRedisLock.java From Mars-Java with MIT License | 6 votes |
/** * 释放锁,使用你自己创建的jedis对象 * * @param key 键 * @param value 值 * @param shardedJedis 自己创建的jedis对象 * @return */ public boolean unlock(String key, String value, ShardedJedis shardedJedis) { try { if (shardedJedis == null) { return false; } String val = shardedJedis.get(key); if (val != null && val.equals(value)) { shardedJedis.del(key); } return true; } catch (Exception e) { logger.error("释放redis锁发生异常", e); return false; } finally { marsRedisTemplate.recycleJedis(shardedJedis); } }
Example 2
Source File: RedisClientTemplate.java From spring-boot-seed with MIT License | 6 votes |
/** * 删除某个值 * * @param key key * @return result */ public Long del(String key) { Long result = null; ShardedJedis shardedJedis = getRedisClient(); if (shardedJedis == null) { return null; } try { result = shardedJedis.del(key); } catch (Exception e) { log.error("RedisClientTemplate del error !", e); } finally { shardedJedis.close(); } return result; }
Example 3
Source File: RedisShardedPoolUtil.java From mmall20180107 with Apache License 2.0 | 6 votes |
public static Long delete(String key){ ShardedJedis jedis = null; Long result = null; try { jedis = RedisShardedPool.getJedis(); result = jedis.del(key); } catch (Exception e) { log.error("delete key:{} error",key,e); RedisShardedPool.returnBrokenResource(jedis); e.printStackTrace(); } RedisShardedPool.returnResource(jedis); return result; }
Example 4
Source File: RedisCacheClient.java From AsuraFramework with Apache License 2.0 | 6 votes |
/** * 从string中删除对象 */ @Override public void del(String key) { ShardedJedis redis = null; try { redis = pool.getResource(); key = getKeyAll(key); redis.del(key); } catch (RuntimeException e) { if(redis != null ) { pool.returnBrokenResource(redis); } logger.error("redis hdel(String key, String... fields):", e); } finally{ if(redis != null ) { pool.returnResource(redis); } } }
Example 5
Source File: JedisCacheService.java From howsun-javaee-framework with Apache License 2.0 | 6 votes |
@Override public long remove(String key) { ShardedJedis jedis = null; try { jedis = cacheFactory.getResource(); return jedis.del(key); } catch (Exception e) { log.error("删除缓存失败:", e); } finally{ if(jedis != null){ try {cacheFactory.returnResource(jedis);} catch (Exception e2) { log.error("不能释放缓存操纵对象:",e2); } } } return -1; }
Example 6
Source File: MarsRedisTemplate.java From Mars-Java with MIT License | 5 votes |
/** * 根据key删除数据 * @param key */ public void del(byte[] key) { ShardedJedis jedis = null; try { jedis = getShardedJedis(); jedis.del(key); } catch (Exception e) { logger.error("delString error:" + key, e); } finally { recycleJedis(jedis); } }
Example 7
Source File: JedisUtil.java From xxl-sso with GNU General Public License v3.0 | 5 votes |
/** * Delete key * * @param key * @return Integer reply, specifically: * an integer greater than 0 if one or more keys were removed * 0 if none of the specified key existed */ public static Long del(String key) { Long result = null; ShardedJedis client = getInstance(); try { result = client.del(key); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { if (client != null) { client.close(); } } return result; }
Example 8
Source File: RedisShardedPoolUtil.java From mmall-kay-Java with Apache License 2.0 | 5 votes |
public static Long del(String key){ ShardedJedis jedis = null; Long result=null; try { jedis = RedisShardedPool.getJedis(); result = jedis.del(key); } catch (Exception e) { log.error("del key:{} error",key,e); RedisShardedPool.returnBrokenResource(jedis); return result; } RedisShardedPool.returnResource(jedis); return result; }
Example 9
Source File: JedisManager.java From es-service-parent with Apache License 2.0 | 5 votes |
/** * del * * @param key */ public boolean del(String key) { ShardedJedis shardedJedis = shardedJedisPool.getResource(); try { return shardedJedis.del(key) == 1; } catch (Exception e) { shardedJedis.close(); return false; } }
Example 10
Source File: ShardedRedisCache.java From framework with Apache License 2.0 | 5 votes |
/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param key <br> */ @Override protected void evict(final byte[] key) { ShardedJedis shardedJedis = null; try { shardedJedis = shardedPool.getResource(); shardedJedis.del(key); } finally { if (shardedJedis != null) { shardedJedis.close(); } } }
Example 11
Source File: ShardedRedisCache.java From framework with Apache License 2.0 | 5 votes |
/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param nodeName */ @Override protected void removeNode(final byte[] nodeName) { ShardedJedis shardedJedis = null; try { shardedJedis = shardedPool.getResource(); shardedJedis.del(nodeName); } finally { if (shardedJedis != null) { shardedJedis.close(); } } }