當前位置: 首頁>>代碼示例>>Java>>正文


Java Jedis.hdel方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:22,代碼來源:JedisQueueStore.java

示例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;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:18,代碼來源:JedisCacheManager.java

示例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);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:24,代碼來源:JedisSegmentQueueStore.java

示例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;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:25,代碼來源:RedisService.java

示例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();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:27,代碼來源:RedisManager.java

示例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);
	}
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:21,代碼來源:JedisSessionDAO.java

示例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);
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:14,代碼來源:JedisCacheManager.java

示例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;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:22,代碼來源:JedisUtils.java

示例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;
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:34,代碼來源:RedisService.java

示例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);
    }

}
 
開發者ID:bitstd,項目名稱:bitstd,代碼行數:14,代碼來源:RedisCacheWithoutCluster.java

示例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;
}
 
開發者ID:TwoDragonLake,項目名稱:tdl-seckill,代碼行數:21,代碼來源:RedisUtil.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:29,代碼來源:RedisRegistry.java

示例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;
}
 
開發者ID:mmdsyl,項目名稱:BLOG-Microservice,代碼行數:8,代碼來源:JedisClientPool.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:zhuxiaolei,項目名稱:dubbo2,代碼行數:29,代碼來源:RedisRegistry.java

示例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;
}
 
開發者ID:wxiaoqi,項目名稱:ace-cache,代碼行數:16,代碼來源:RedisServiceImpl.java


注:本文中的redis.clients.jedis.Jedis.hdel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。