當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。