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


Java Jedis.del方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Jedis.del方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.del方法的具體用法?Java Jedis.del怎麽用?Java Jedis.del使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.del方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void init(Object obj) {
    super.init(obj);
    PropertiesWrapper propertiesWrapper = (PropertiesWrapper) obj;
    if (propertiesWrapper.getBooleanProperty("redis", false)) {
        redis = true;
    }
    //清空之前的數據
    Jedis jedis = getJedis();
    jedis.del(RedisUtils.createKeyWithNameSpace(ACTOR_GLOBAL_PATH_INDEX, nameSpace));

    MapStructure<String> mapStructure = RedisStrutureBuilder.ofMap(jedis, String.class).withNameSpace(nameSpace).build();
    jedis.del(RedisUtils.createKeyWithNameSpace(AREA_MANAGER_INDEX, nameSpace));
    jedis.close();
    super.setActive();
}
 
開發者ID:zerosoft,項目名稱:CodeBroker,代碼行數:17,代碼來源:CacheManager.java

示例2: clear

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void clear(String queueID) {
    if (!lockQueue(queueID)) {
        return;
    }
    @Cleanup Jedis jedis = jedisPool.getResource();
    try {
        for (String sliceID : sliceQueue(queueID)) {
            jedis.del(makePoolQueueKey(queueID, sliceID));
        }
        jedis.del(makeDataKey(queueID));
        jedis.del(makeSliceQueueKey(queueID));
    } finally {
        unLockQueue(queueID);
    }
}
 
開發者ID:virjar,項目名稱:vscrawler,代碼行數:17,代碼來源:JedisSegmentQueueStore.java

示例3: setList

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 設置List緩存
 *
 * @param key          鍵
 * @param value        值
 * @param cacheSeconds 超時時間,0為不超時
 * @return
 */
public static long setList(String key, List<String> value, int cacheSeconds) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			jedis.del(key);
		}
		result = jedis.rpush(key, (String[]) value.toArray());
		if (cacheSeconds != 0) {
			jedis.expire(key, cacheSeconds);
		}
		logger.debug("setList {} = {}", key, value);
	} catch (Exception e) {
		logger.warn("setList {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:29,代碼來源:JedisUtils.java

示例4: deleteByKey

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public long deleteByKey(int dbIndex, byte[] key) throws Exception {
    Jedis jedis = null;
    try {
        jedis = getJedis();
        jedis.select(dbIndex);
        Long result = jedis.del(key);
        return result;
    } catch (Exception e) {
        throw e;
    } finally {
    	if(null != jedis)
    	{
    		jedis.close();
    	}
    }
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:17,代碼來源:RedisManager.java

示例5: delObject

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 刪除緩存
 * @param key 鍵
 * @return
 */
public static long delObject(String key) {
	long result = 0;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(getBytesKey(key))){
			result = jedis.del(getBytesKey(key));
			logger.debug("delObject {}", key);
		}else{
			logger.debug("delObject {} not exists", key);
		}
	} catch (Exception e) {
		logger.warn("delObject {}", key, e);
	} finally {
		returnResource(jedis);
	}
	return result;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:24,代碼來源:JedisUtils.java

示例6: delObject

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public boolean delObject(String key) {
    log.trace("strar delete cache with " + key);
    Jedis jedis = null;
    try {
        jedis = redisConnection.getJedis();
        jedis.select(dbIndex);
        return jedis.del(key.getBytes()) > 0;
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }

    return false;
}
 
開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:18,代碼來源:CacheServiceRedisImpl.java

示例7: 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

示例8: doDelete

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 刪除會話
 * 當會話過期/會話停止時會調用
 * @param session
 */
@Override
protected void doDelete(Session session) {
    logger.debug("begin doDelete {}", session);
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        jedis.del(prefix + session.getId());
        this.uncache(session.getId());
        logger.debug("shiro session id {} 被刪除", session.getId());
    } catch (Exception e){
        logger.warn("刪除session失敗",e);
    } finally {
        jedis.close();
    }
}
 
開發者ID:ZhuXS,項目名稱:Spring-Shiro-Spark,代碼行數:21,代碼來源:ShiroSessionDao.java

示例9: del

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void del(String key) {
    Jedis jedis = null;
    try {
        jedis = getJedis();
        if (jedis != null) {
            jedis.del(key);
        } else {
            logger.error("del opt connection null error!");
        }
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
            jedis = null;
        }
        logger.error("delete connect error:", e);
    } finally {
        returnJedisResource(jedis);
    }
}
 
開發者ID:Zephery,項目名稱:newblog,代碼行數:20,代碼來源:JedisUtil.java

示例10: processExpires

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void processExpires() {
	long timeStart = System.currentTimeMillis();
	int expired = 0;
	Jedis jedis = null;
	boolean error = true;
	try {
		// retrieve all session IDs from redis without changing their lastAccessedTime
		jedis = acquireConnection();
		Set<String> sessionIds = jedis.keys("*");
		if (log.isDebugEnabled()) {
			log.debug(String.format("Starting to expire sessions, checking %s", sessionIds.size()));
		}
		for (String sessionId : sessionIds) {
			try {
				byte[] data = jedis.get(sessionId.getBytes());
				RedisSession session = createEmptySession();
				serializer.deserializeInto(data, session, new SessionSerializationMetadata());
				if (null != session && !session.isValid()) {
					expired++;
				}
			} catch (IOException | ReflectiveOperationException e) {
				log.error(String.format("error reading session %s", sessionId));
				jedis.del(sessionId.getBytes());
			}
		}
		error = false;
	} finally {
		if (jedis != null) {
			returnConnection(jedis, error);
		}
	}

	long duration = System.currentTimeMillis() - timeStart;
	if (log.isDebugEnabled()) {
		log.debug(String.format("Expired %s sessions in %sms", expired, duration));
	}
	processingTime += duration;
}
 
開發者ID:appNG,項目名稱:appng-tomcat-session,代碼行數:40,代碼來源:RedisSessionManager.java

示例11: del

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public boolean del(String key) {
	Jedis jedis = getJedisPool().getResource();
	try {
		jedis.del(key);
		return true;
	} catch (Exception e) {
		logger.error("del ", e);
		return false;
	} finally {
		getJedisPool().returnResource(jedis);
	}
}
 
開發者ID:zh-cn-trio,項目名稱:trioAop,代碼行數:14,代碼來源:RedisStringOperationImpl.java

示例12: del

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Long del(String key) {
	Jedis jedis = jedisPool.getResource();
	Long result = jedis.del(key);
	jedis.close();
	return result;
}
 
開發者ID:mmdsyl,項目名稱:BLOG-Microservice,代碼行數:8,代碼來源:JedisClientPool.java

示例13: testCreateRedisPoolAndConnection

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Test
public void testCreateRedisPoolAndConnection() throws Exception {
    RedisPools result = poolManagement.createRedisPoolAndConnection(property);
    Jedis jedis = result.getJedis();
    jedis.set("names","testCreateRedisPoolAndConnection");
    Assert.assertEquals("testCreateRedisPoolAndConnection",jedis.get("names"));
    jedis.del("names");
}
 
開發者ID:Kuangcp,項目名稱:MythRedisClient,代碼行數:9,代碼來源:PoolManagementTest.java

示例14: deletePlayerPearl

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void deletePlayerPearl(UUID player, UUID pearl)
{
    Jedis jedis = SamaGamesAPI.get().getBungeeResource();

    if (jedis == null)
        return;

    if (jedis.exists("pearls:" + player.toString() + ":" + pearl.toString()))
        jedis.del("pearls:" + player.toString() + ":" + pearl.toString());

    jedis.close();
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:13,代碼來源:GraouManager.java

示例15: finalizePearlCrafting

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public void finalizePearlCrafting(Player player, UUID craftingPearlUUID)
{
    Jedis jedis = SamaGamesAPI.get().getBungeeResource();

    if (jedis == null)
        return;

    CraftingPearl craftingPearl = null;

    if (jedis.exists("crafting-pearls:" + player.getUniqueId().toString() + ":" + craftingPearlUUID.toString()))
        craftingPearl = new Gson().fromJson(jedis.get("crafting-pearls:" + player.getUniqueId().toString() + ":" + craftingPearlUUID.toString()), CraftingPearl.class);

    if (craftingPearl == null)
    {
        jedis.close();
        return;
    }

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, 7);

    Pearl craftedPearl = new Pearl(craftingPearl.getUUID(), craftingPearl.getStars(), calendar.getTime().getTime());
    this.addPearlToPlayer(player, craftedPearl);

    jedis.del("crafting-pearls:" + player.getUniqueId().toString() + ":" + craftingPearlUUID.toString());

    jedis.close();

    this.hub.getInteractionManager().getGraouManager().update(player);
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:31,代碼來源:WellManager.java


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