当前位置: 首页>>代码示例>>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;未经允许,请勿转载。