本文整理了Java中redis.clients.jedis.Transaction.lpush()
方法的一些代码示例,展示了Transaction.lpush()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.lpush()
方法的具体详情如下:
包路径:redis.clients.jedis.Transaction
类名称:Transaction
方法名:lpush
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long lPush(byte[] key, byte[]... values) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(values, "Values must not be null!");
Assert.noNullElements(values, "Values must not contain null elements!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values)));
return null;
}
return connection.getJedis().lpush(key, values);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: mindwind/craft-atom
private void lpush0(String key, String... values) {
t.lpush(key, values);
}
代码示例来源:origin: ai.grakn/redisq
multi.lpush(queueName, id);
multi.exec();
代码示例来源:origin: OpenNMS/opennms
@Override
public void merge(Context context, Resource resource, ResourceMetadata metadata) {
final Optional<ResourceMetadata> o = get(context, resource);
try (Jedis jedis = m_pool.getResource()) {
if (!o.isPresent()) {
final ResourceMetadata newMetadata = new ResourceMetadata();
newMetadata.merge(metadata);
final Transaction t = jedis.multi();
final byte[] key = key(METADATA_PREFIX, context.getId(), resource.getId());
t.set(key, conf.asByteArray(newMetadata));
// Index the key, element by element, in order to support calls to getResourceIdsWithPrefix()
final List<String> elements = Lists.newArrayList(SEARCH_PREFIX, context.getId());
for (String el : m_resourceIdSplitter.splitIdIntoElements(resource.getId())) {
elements.add(el);
t.lpush(m_resourceIdSplitter.joinElementsToId(elements).getBytes(), key);
}
// Update the keys in transaction
t.exec();
} else if (o.get().merge(metadata)) {
// Update the value stored in the cache if it was changed as a result of the merge
jedis.set(key(METADATA_PREFIX, context.getId(), resource.getId()), conf.asByteArray(o.get()));
}
}
}
代码示例来源:origin: org.opennms.features/org.opennms.features.newts
@Override
public void merge(Context context, Resource resource, ResourceMetadata metadata) {
final Optional<ResourceMetadata> o = get(context, resource);
try (Jedis jedis = m_pool.getResource()) {
if (!o.isPresent()) {
final ResourceMetadata newMetadata = new ResourceMetadata();
newMetadata.merge(metadata);
final Transaction t = jedis.multi();
final byte[] key = key(METADATA_PREFIX, context.getId(), resource.getId());
t.set(key, conf.asByteArray(newMetadata));
// Index the key, element by element, in order to support calls to getResourceIdsWithPrefix()
final List<String> elements = Lists.newArrayList(SEARCH_PREFIX, context.getId());
for (String el : m_resourceIdSplitter.splitIdIntoElements(resource.getId())) {
elements.add(el);
t.lpush(m_resourceIdSplitter.joinElementsToId(elements).getBytes(), key);
}
// Update the keys in transaction
t.exec();
} else if (o.get().merge(metadata)) {
// Update the value stored in the cache if it was changed as a result of the merge
jedis.set(key(METADATA_PREFIX, context.getId(), resource.getId()), conf.asByteArray(o.get()));
}
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long lPush(byte[] key, byte[]... values) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(values, "Values must not be null!");
Assert.noNullElements(values, "Values must not contain null elements!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values)));
return null;
}
return connection.getJedis().lpush(key, values);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Long lPush(byte[] key, byte[]... values) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(values, "Values must not be null!");
Assert.noNullElements(values, "Values must not contain null elements!");
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values)));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values)));
return null;
}
return connection.getJedis().lpush(key, values);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: ai.grakn/redisq
@Override
public void push(T document) {
long timestampMs = System.currentTimeMillis();
String serialized;
String stateSerialized;
try {
serialized = mapper.serialize(new TimedWrap<>(document, timestampMs));
stateSerialized = stateMapper.serialize(new StateInfo(NEW, timestampMs, ""));
} catch (SerializationException e) {
serializationErrors.mark();
throw new RedisqException("Could not serialize element " + document.getIdAsString(), e);
}
LOG.debug("Jedis active: {}, idle: {}", jedisPool.getNumActive(), jedisPool.getNumIdle());
try (Jedis jedis = jedisPool.getResource(); Timer.Context ignored = pushTimer.time();) {
Transaction transaction = jedis.multi();
String id = document.getIdAsString();
String lockId = names.lockKeyFromId(id);
transaction.setex(lockId, lockTime, "locked");
transaction.lpush(queueName, id);
transaction.setex(names.contentKeyFromId(id), ttlStateInfo, serialized);
transaction.setex(names.stateKeyFromId(id), ttlStateInfo, stateSerialized);
transaction.publish(names.stateChannelKeyFromId(id), stateSerialized);
transaction.exec();
LOG.debug("Pushed {} with lockTime {}s lock id: {}", id, lockTime, lockId);
}
}
内容来源于网络,如有侵权,请联系作者删除!