当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.del方法代码示例

本文整理汇总了Java中redis.clients.jedis.Transaction.del方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.del方法的具体用法?Java Transaction.del怎么用?Java Transaction.del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Transaction的用法示例。


在下文中一共展示了Transaction.del方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteMulti

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public boolean deleteMulti(String... keys) {
  Jedis jedis = null;
  try {
    jedis = pool.getResource();
    Transaction trans = jedis.multi();
    for (String key : keys) {
      trans.del(key.getBytes());
    }
    trans.exec();
    pool.returnResource(jedis);
  } catch (Exception e) {
    LOGGER.warn("Failed to delete key from cache {0}", keys, e);
    pool.returnBrokenResource(jedis);
    return false;
  }
  return true;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:19,代码来源:RedisMemcacheService.java

示例2: doRelease

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
protected void doRelease(String token) {
    jedisClient.watch(lockName);

    String currentToken = jedisClient.get(lockName);
    if (currentToken == null){
        jedisClient.unwatch();
        return;
    }

    if (currentToken.equals(token)) {
        Transaction t = jedisClient.multi();
        t.del(lockName);
        t.exec();
    } else {
        jedisClient.unwatch();
    }
}
 
开发者ID:wushibin,项目名称:redislock,代码行数:19,代码来源:RedisLock.java

示例3: remove

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public <E extends EntityType, T extends TokenType> AuthenticationToken<E, T> remove(final TokenProxy<E, T> tokenProxy) throws IOException {
    try(final Jedis jedis = jedisPool.getResource()) {
        final byte[] keyBytes = serialize(tokenProxy);

        final Transaction transaction = jedis.multi();

        final Response<byte[]> oldTokenResponse = transaction.get(keyBytes);
        transaction.del(keyBytes);

        transaction.exec();

        //noinspection unchecked
        return (AuthenticationToken<E, T>) deserialize(oldTokenResponse.get());
    }
}
 
开发者ID:hpe-idol,项目名称:redis-hod-token-repository,代码行数:17,代码来源:RedisTokenRepository.java

示例4: doCallback

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public void doCallback(Transaction tx) {
	for (Command cmd : redisCommands) {
		switch (cmd.getOp()) {
			case SET:
				tx.set(cmd.getCacheKey(), cmd.getCacheValue());
				break;
			case MOD:
				tx.set(cmd.getCacheKey(), cmd.getCacheValue());
				break;
			case DEL:
				tx.del(cmd.getCacheKey());
				break;
			case ADD_MEMBERS:
				tx.sadd(cmd.getCacheGroupKey(), cmd.getGroupValues());
				break;
			case DEL_MEMBERS:
				tx.srem(cmd.getCacheGroupKey(), cmd.getGroupValues());
				break;
			case SETS:
				tx.mset(cmd.getKeyvalues());
			default:
				break;
		}
	}
}
 
开发者ID:leopardoooo,项目名称:easyooo-framework,代码行数:27,代码来源:DefaultRedisTransactionCallback.java

示例5: releaseLock

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
/**
 * 释放锁
 *
 * @param lockName   锁的key
 * @param identifier 释放锁的标识
 */
public boolean releaseLock(String lockName, String identifier){
    Jedis conn = null;
    String lockKey = lockPrefix + lockName;
    boolean retFlag = false;
    ShardedJedis shardedJedis = jedisPool.getResource();
    try {
        conn = shardedJedis.getShard(lockKey);
        while (true) {
            // 监视lock,准备开始事务
            conn.watch(lockKey);
            // 通过前面返回的value值判断是不是该锁,若是该锁,则删除,释放锁
            if (identifier.equals(conn.get(lockKey))) {
                Transaction transaction = conn.multi();
                transaction.del(lockKey);
                List<Object> results = transaction.exec();
                if (results == null) {
                    continue;
                }
                retFlag = true;
            }
            conn.unwatch();
            break;
        }
    } catch (JedisException e) {
        LOGGER.error("releaseLock found exception", e);
    } finally {
        if (conn != null) {
            jedisPool.returnResource(shardedJedis);
        }
    }
    return retFlag;
}
 
开发者ID:bubicn,项目名称:bubichain-sdk-java,代码行数:39,代码来源:DistributedLock.java

示例6: unlock

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public boolean unlock(String key, String identifier) {
  Preconditions.checkNotNull(key);
  Preconditions.checkNotNull(identifier);

  String fullKey = RedisKey.fullKey(group, key) + LOCKER_NAME_SUFFIX;
  Jedis jedis = RedisHandler.getJedis();

  while (true) {
    // 监视lock,准备开始事务
    jedis.watch(fullKey);
    // 看看是不是自己的锁
    if (identifier.equals(jedis.get(fullKey))) {
      Transaction transaction = jedis.multi();
      transaction.del(fullKey);
      List<Object> results = transaction.exec();
      if (results == null) {
        continue;
      }
      jedis.close();
      return true;
    }
    jedis.unwatch();
    break;
  }

  jedis.close();
  return false;
}
 
开发者ID:rcarlosdasilva,项目名称:weixin,代码行数:30,代码来源:SimpleRedisStorage.java

示例7: invalidate

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public void invalidate(HttpServerExchange exchange) {
    try (Jedis jedis = sessionManager.jedisPool.getResource()) {
        Transaction transaction = jedis.multi();
        transaction.del(sessionId);
        transaction.del(sessionId + CREATED_FIELD);
        transaction.exec();
    }

    if (exchange != null) {
        sessionConfig.clearSession(exchange, this.getId());
    }
}
 
开发者ID:coat,项目名称:undertow-redis-session,代码行数:14,代码来源:RedisSessionManager.java

示例8: del

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Test public void del() {
    // GIVEN
    this.jedis.lpush(KEY, VALUE);
    Transaction tr = this.jedis.multi();

    // WHEN
    tr.del(KEY);
    tr.exec();

    // THEN
    assertFalse(this.jedis.exists(KEY));
}
 
开发者ID:vdurmont,项目名称:fake-jedis,代码行数:13,代码来源:FakeTransactionTest.java

示例9: del

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public void del(String sessionsKey, String key) {
    try(Jedis jedis = this.jedisPool.getResource()) {
        Transaction t = jedis.multi();
        t.srem(sessionsKey, key);
        t.del(key);
        t.exec();
    }
}
 
开发者ID:pivotalsoftware,项目名称:session-managers,代码行数:10,代码来源:JedisNodeClient.java

示例10: clean

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public void clean(String sessionsKey) {
    try(Jedis jedis = this.jedisPool.getResource()) {
        Set<String> sessions = jedis.smembers(sessionsKey);
        String[] sessionsArray = sessions.toArray(new String[sessions.size()]);

        Transaction t = jedis.multi();
        t.srem(sessionsKey, sessionsArray);
        t.del(sessionsArray);
        t.exec();
    }
}
 
开发者ID:pivotalsoftware,项目名称:session-managers,代码行数:13,代码来源:JedisNodeClient.java

示例11: delete

import redis.clients.jedis.Transaction; //导入方法依赖的package包/类
@Override
public boolean delete(int space, ByteString key, Modifier... modifiers) throws IOException {
    try (Pooled<RedisClient> lease = clientPool.borrow()) {
        Jedis client = lease.get().getClient();

        if (client.getDB().intValue() != space) {
            client.select(space);
        }

        byte[] keyBytes = key.toByteArray();
        if (modifiers == null || modifiers.length == 0) {
            long deleted = client.del(keyBytes);
            return deleted == 1;
        }

        Object ifVersion = null;
        for (Modifier modifier : modifiers) {
            if (modifier instanceof IfVersion) {
                Preconditions.checkArgument(ifVersion == null);
                ifVersion = ((IfVersion) modifier).version;
                Preconditions.checkArgument(ifVersion != null);
            } else {
                Preconditions.checkArgument(false);
            }
        }

        Preconditions.checkState(ifVersion != null);

        try (Atomic atomic = Atomic.start(client)) {
            client.watch(keyBytes);

            byte[] existing = client.get(keyBytes);
            if (existing == null) {
                return false;
            }

            if (!Arrays.equals(existing, ((ByteString) ifVersion).toByteArray())) {
                return false;
            }

            Transaction writes = atomic.startWrites();

            Response<Long> deletedCount = writes.del(keyBytes);

            if (!atomic.commit()) {
                return false;
            }

            return deletedCount.get().longValue() == 1;
        }
    }

}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:54,代码来源:RedisKeyValueStore.java


注:本文中的redis.clients.jedis.Transaction.del方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。