本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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");
}
示例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();
}
示例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);
}