本文整理匯總了Java中redis.clients.jedis.Jedis.hdel方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.hdel方法的具體用法?Java Jedis.hdel怎麽用?Java Jedis.hdel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.hdel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public ResourceItem remove(String queueID, String key) {
if (!lockQueue(queueID)) {
return null;
}
Jedis jedis = jedisPool.getResource();
try {
String dataJson = jedis.hget(makeDataKey(queueID), key);
if (isNil(dataJson)) {
return null;
} else {
jedis.hdel(makeDataKey(queueID), key);
//lrem很消耗資源,盡量減少該命令操作
jedis.lrem(makePoolQueueKey(queueID), 1, key);
}
return JSONObject.toJavaObject(JSON.parseObject(dataJson), ResourceItem.class);
} finally {
IOUtils.closeQuietly(jedis);
unLockQueue(queueID);
}
}
示例2: remove
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public V remove(K key) throws CacheException {
V value = null;
Jedis jedis = null;
try {
jedis = JedisUtils.getResource();
value = (V) JedisUtils.toObject(jedis.hget(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key)));
jedis.hdel(JedisUtils.getBytesKey(cacheKeyName), JedisUtils.getBytesKey(key));
logger.debug("remove {} {}", cacheKeyName, key);
} catch (Exception e) {
logger.warn("remove {} {}", cacheKeyName, key, e);
} finally {
JedisUtils.returnResource(jedis);
}
return value;
}
示例3: remove
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public ResourceItem remove(String queueID, String key) {
if (!lockQueue(queueID)) {
return null;
}
@Cleanup Jedis jedis = jedisPool.getResource();
try {
String dataJson = jedis.hget(makeDataKey(queueID), key);
if (isNil(dataJson)) {
return null;
}
jedis.hdel(makeDataKey(queueID), key);
// lrem很消耗資源,盡量減少該命令操作
for (String slice : sliceQueue(queueID)) {
if (jedis.lrem(makePoolQueueKey(queueID, slice), 1, key) > 0) {
break;
}
}
return JSONObject.toJavaObject(JSON.parseObject(dataJson), ResourceItem.class);
} finally {
unLockQueue(queueID);
}
}
示例4: deleteHField
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 刪除key
*
* @param key
*/
public boolean deleteHField(String key, String field) {
Jedis jedis = null;
boolean success = true;
boolean ret = false;
try {
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return false;
}
ret = (jedis.hdel(key, field) > 0);
} catch (Exception e) {
success = false;
releaseBrokenReidsSource(jedis, key, "deleteHField", e, false);
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例5: delByMapKey
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 刪除Map裏的值
* @param mapKey
* @param dkey
* @return
*/
public Object delByMapKey(String mapKey ,String...dkey) throws Exception {
Jedis jds = null;
try {
jds = getJedis();
jds.select(0);
byte[][] dx = new byte[dkey.length][];
for (int i = 0; i < dkey.length; i++) {
dx[i] = dkey[i].getBytes();
}
Long result = jds.hdel(mapKey.getBytes(), dx);
return result;
} catch (Exception e) {
throw e;
} finally {
if(jds != null)
{
jds.close();
}
}
}
示例6: delete
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void delete(Session session) {
if (session == null || session.getId() == null) {
return;
}
Jedis jedis = null;
try {
jedis = JedisUtils.getResource();
jedis.hdel(JedisUtils.getBytesKey(sessionKeyPrefix), JedisUtils.getBytesKey(session.getId().toString()));
jedis.del(JedisUtils.getBytesKey(sessionKeyPrefix + session.getId()));
logger.debug("delete {} ", session.getId());
} catch (Exception e) {
logger.error("delete {} ", session.getId(), e);
} finally {
JedisUtils.returnResource(jedis);
}
}
示例7: clear
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void clear() throws CacheException {
Jedis jedis = null;
try {
jedis = JedisUtils.getResource();
jedis.hdel(JedisUtils.getBytesKey(cacheKeyName));
logger.debug("clear {}", cacheKeyName);
} catch (Exception e) {
logger.error("clear {}", cacheKeyName, e);
} finally {
JedisUtils.returnResource(jedis);
}
}
示例8: mapRemove
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 移除Map緩存中的值
*
* @param key 鍵
* @param mapKey 值
* @return
*/
public static long mapRemove(String key, String mapKey) {
long result = 0;
Jedis jedis = null;
try {
jedis = getResource();
result = jedis.hdel(key, mapKey);
logger.debug("mapRemove {} {}", key, mapKey);
} catch (Exception e) {
logger.warn("mapRemove {} {}", key, mapKey, e);
} finally {
returnResource(jedis);
}
return result;
}
示例9: deleteList
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 批量刪除對象
*
* @param key
* @param list
*/
public boolean deleteList(String key, List<RedisListInterface> list) {
Jedis jedis = null;
boolean success = true;
boolean ret = false;
try {
String keys[] = new String[list.size()];
// String keyNames[] = null;
// Map<String, String> keyMap = null;
int index = 0;
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return false;
}
for (RedisListInterface po : list) {
keys[index++] = ObjectUtils.getFieldsValueStr(po, po.getSubUniqueKey());
}
ret = (jedis.hdel(key, keys) > 0);
} catch (Exception e) {
success = false;
returnBrokenResource(jedis, "deleteList:" + key, e);
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例10: delHashCache
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void delHashCache(String key, String... fields) {
Jedis jedis = null;
try {
jedis = pool.getResource();
jedis.hdel(key, fields);
} catch (Exception var8) {
throw new RuntimeException(var8);
} finally {
pool.returnResourceObject(jedis);
}
}
示例11: setRedisData
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* 向redis中存入數據
*
* @param key 鍵值
* @param fieldName 文件名
* @return boolean
*/
public boolean setRedisData(String key, String fieldName) {
Jedis jedis = null;
try {
jedis = getConnect();
jedis.hdel(key.getBytes(), fieldName.getBytes());
} catch (Exception e) {
logger.error("redis setRedisData data failed!", e);
return false;
} finally {
close(jedis);
}
return true;
}
示例12: clean
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
private void clean(Jedis jedis) {
Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
if (keys != null && keys.size() > 0) {
for (String key : keys) {
Map<String, String> values = jedis.hgetAll(key);
if (values != null && values.size() > 0) {
boolean delete = false;
long now = System.currentTimeMillis();
for (Map.Entry<String, String> entry : values.entrySet()) {
URL url = URL.valueOf(entry.getKey());
if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
long expire = Long.parseLong(entry.getValue());
if (expire < now) {
jedis.hdel(key, entry.getKey());
delete = true;
if (logger.isWarnEnabled()) {
logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
}
}
}
}
if (delete) {
jedis.publish(key, Constants.UNREGISTER);
}
}
}
}
}
示例13: hdel
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Long hdel(String key, String... field) {
Jedis jedis = jedisPool.getResource();
Long result = jedis.hdel(key, field);
jedis.close();
return result;
}
示例14: clean
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
private void clean(Jedis jedis) {
Set<String> keys = jedis.keys(root + Constants.ANY_VALUE);
if (keys != null && keys.size() > 0) {
for (String key : keys) {
Map<String, String> values = jedis.hgetAll(key);
if (values != null && values.size() > 0) {
boolean delete = false;
long now = System.currentTimeMillis();
for (Map.Entry<String, String> entry : values.entrySet()) {
URL url = URL.valueOf(entry.getKey());
if (url.getParameter(Constants.DYNAMIC_KEY, true)) {
long expire = Long.parseLong(entry.getValue());
if (expire < now) {
jedis.hdel(key, entry.getKey());
delete = true;
if (logger.isWarnEnabled()) {
logger.warn("Delete expired key: " + key + " -> value: " + entry.getKey() + ", expire: " + new Date(expire) + ", now: " + new Date(now));
}
}
}
}
if (delete) {
jedis.publish(key, Constants.UNREGISTER);
}
}
}
}
}
示例15: hdel
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Long hdel(String key, String... fields) {
Jedis jedis = null;
Long res = null;
try {
jedis = pool.getResource();
res = jedis.hdel(key, fields);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}