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


Java Transaction.lpush方法代碼示例

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


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

示例1: add

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
public void add(String key, String value) {
    if(fake) {
        ConcurrentLinkedQueue<String> stack = circularStackMap.get(key);
        if(stack==null) {
            synchronized(circularStackMap) {
                stack = circularStackMap.get(key);
                if(stack==null) {
                    stack = new ConcurrentLinkedQueue<String>();
                    circularStackMap.put(key, stack);
                }
            }
        }
        stack.add(value);
        while(stack.size() > capacity) {
            stack.poll();
        }
    } else {
        try(Jedis jedis = jedisPool.getResource()) {
            Transaction transaction = jedis.multi();
            transaction.lpush(key, value);
            transaction.ltrim(key, 0, capacity); // right away trim to capacity so that we can pretend it is a circular list
            transaction.expire(key, expireInSeconds); // don't keep the data forever
            transaction.exec();
        } catch (JedisException e) {
            // make sure we can find back jedis related stuff in kibana
            throw new IllegalStateException("problem connecting to jedis", e);
        }
    }
}
 
開發者ID:Inbot,項目名稱:inbot-es-http-client,代碼行數:30,代碼來源:RedisBackedCircularStack.java

示例2: if_was_in_multi_but_exec_was_called_the_instance_can_be_used

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test public void if_was_in_multi_but_exec_was_called_the_instance_can_be_used() {
    // GIVEN
    Transaction tr = this.jedis.multi();
    tr.lpush(KEY, VALUE);
    tr.exec();

    // WHEN
    boolean result = this.jedis.exists(KEY);

    // THEN
    assertTrue(result);
}
 
開發者ID:vdurmont,項目名稱:fake-jedis,代碼行數:13,代碼來源:FakeJedisTest.java

示例3: emit

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public <P extends Serializable> void emit(final EventChannel<P> channel, final Event<P> event) {
	Assertion.checkNotNull(channel);
	Assertion.checkNotNull(event);
	//----
	try (final Jedis jedis = redisConnector.getResource()) {
		final Transaction tx = jedis.multi();
		final String base64Payload = encodeToBase64(event.getPayload());
		tx.hset("event:" + event.getUuid(), "payload", base64Payload);
		tx.lpush("events:" + channel + ":pending", "event:" + event.getUuid());
		tx.exec();
	}
}
 
開發者ID:KleeGroup,項目名稱:vertigo-labs,代碼行數:15,代碼來源:RedisEventsPlugin2.java

示例4: emit

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public void emit(final String channel, final Event event) {
	Assertion.checkArgNotEmpty(channel);
	Assertion.checkNotNull(event);
	//----
	try (final Jedis jedis = redisConnector.getResource()) {
		final Transaction tx = jedis.multi();
		tx.hset("event:" + event.getUuid(), "payload", event.getPayload());
		tx.lpush("events:" + channel + ":pending", "event:" + event.getUuid());
		tx.exec();
	}

}
 
開發者ID:KleeGroup,項目名稱:vertigo-labs,代碼行數:14,代碼來源:RedisEventsPlugin.java


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