本文整理了Java中redis.clients.jedis.Jedis.lset()
方法的一些代码示例,展示了Jedis.lset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.lset()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:lset
[英]Set a new value as the element at index position of the List at key.
Out of range indexes will generate an error.
Similarly to other list commands accepting indexes, the index can be negative to access elements starting from the end of the list. So -1 is the last element, -2 is the penultimate, and so forth.
Time complexity:
O(N) (with N being the length of the list), setting the first or last elements of the list is O(1).
[中]将新值设置为键处列表索引位置的元素。
超出范围的索引将生成错误。
与接受索引的其他列表命令类似,索引可以是负数,以便从列表末尾开始访问元素。所以-1是最后一个元素,-2是倒数第二个元素,依此类推。
时间复杂性:
O(N)(N是列表的长度),将列表的第一个或最后一个元素设置为O(1)。
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.lset(key, index, value);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.lset(key, index, value);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
public String execute(Jedis connection) {
return connection.lset(keyByte, index, value);
}
}.runBinary(keyByte);
代码示例来源:origin: sohutv/cachecloud
@Override
public String lset(byte[] key, long index, byte[] value) {
Jedis j = getShard(key);
return j.lset(key, index, value);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public String lset(String key, long index, String value) {
Jedis j = getShard(key);
return j.lset(key, index, value);
}
代码示例来源:origin: caoxinyu/RedisClient
@Override
protected void command() {
jedis.select(db);
jedis.lset(key, index, value);
}
代码示例来源:origin: Netflix/conductor
@Override
public String lset(String key, long index, String value) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.lset(key, index, value);
} finally {
if (jedis != null)
jedis.close();
}
}
代码示例来源:origin: jfinal/jfinal
/**
* 将列表 key 下标为 index 的元素的值设置为 value 。
* 当 index 参数超出范围,或对一个空列表( key 不存在)进行 LSET 时,返回一个错误。
* 关于列表下标的更多信息,请参考 LINDEX 命令。
*/
public String lset(Object key, long index, Object value) {
Jedis jedis = getJedis();
try {
return jedis.lset(keyToBytes(key), index, valueToBytes(value));
}
finally {close(jedis);}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public void lSet(byte[] key, long index, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newStatusResult(connection.getRequiredPipeline().lset(key, index, value)));
return;
}
if (isQueueing()) {
transaction(connection.newStatusResult(connection.getRequiredTransaction().lset(key, index, value)));
return;
}
connection.getJedis().lset(key, index, value);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: yrain/smart-cache
@Override
String doInJedis(Jedis jedis) {
return jedis.lset(key, index, value);
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public String execute(Jedis connection) {
return connection.lset(key, index, value);
}
}.run(key);
代码示例来源:origin: gresrun/jesque
/**
* {@inheritDoc}
*/
@Override
public Void doWork(final Jedis jedis) throws Exception {
final String failedKey = key(FAILED);
final String randId = UUID.randomUUID().toString();
jedis.lset(failedKey, index, randId);
jedis.lrem(failedKey, 1, randId);
return null;
}
});
代码示例来源:origin: apache/servicemix-bundles
@Override
public String lset(final byte[] key, final long index, final byte[] value) {
Jedis j = getShard(key);
return j.lset(key, index, value);
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public String lset(final String key, final long index, final String value) {
Jedis j = getShard(key);
return j.lset(key, index, value);
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public String lset(String key, long index, String value) {
String command = "lset";
return instrumented(command, payloadSize(value), () -> delegated.lset(key, index, value));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public String lset(byte[] key, long index, byte[] value) {
String command = "lset";
return instrumented(command, payloadSize(value), () -> delegated.lset(key, index, value));
}
代码示例来源:origin: gresrun/jesque
/**
* {@inheritDoc}
*/
@Override
public Date doWork(final Jedis jedis) throws Exception {
final Date retriedAt = new Date();
final JobFailure failure = failures.get(0);
failure.setRetriedAt(retriedAt);
jedis.lset(key(FAILED), index, ObjectMapperFactory.get().writeValueAsString(failure));
enqueue(jedis, failure.getQueue(), failure.getPayload());
return retriedAt;
}
});
代码示例来源:origin: xetorthio/rmq
public String lset(int index, String value) {
Jedis jedis = getResource();
String lset = jedis.lset(key(), index, value);
returnResource(jedis);
return lset;
}
代码示例来源:origin: xetorthio/johm
public String lset(int index, String value) {
Jedis jedis = getResource();
String lset = jedis.lset(key(), index, value);
returnResource(jedis);
return lset;
}
代码示例来源:origin: com.jfinal/jfinal
/**
* 将列表 key 下标为 index 的元素的值设置为 value 。
* 当 index 参数超出范围,或对一个空列表( key 不存在)进行 LSET 时,返回一个错误。
* 关于列表下标的更多信息,请参考 LINDEX 命令。
*/
public String lset(Object key, long index, Object value) {
Jedis jedis = getJedis();
try {
return jedis.lset(keyToBytes(key), index, valueToBytes(value));
}
finally {close(jedis);}
}
内容来源于网络,如有侵权,请联系作者删除!