本文整理了Java中redis.clients.jedis.JedisCommands.hmset()
方法的一些代码示例,展示了JedisCommands.hmset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JedisCommands.hmset()
方法的具体详情如下:
包路径:redis.clients.jedis.JedisCommands
类名称:JedisCommands
方法名:hmset
暂无
代码示例来源:origin: brianfrankcooper/YCSB
@Override
public Status update(String table, String key,
Map<String, ByteIterator> values) {
return jedis.hmset(key, StringByteIterator.getStringMap(values))
.equals("OK") ? Status.OK : Status.ERROR;
}
代码示例来源:origin: brianfrankcooper/YCSB
@Override
public Status insert(String table, String key,
Map<String, ByteIterator> values) {
if (jedis.hmset(key, StringByteIterator.getStringMap(values))
.equals("OK")) {
jedis.zadd(INDEX_KEY, hash(key), key);
return Status.OK;
}
return Status.ERROR;
}
代码示例来源:origin: mpusher/mpush
/**
* 设置 key 指定的哈希集中指定字段的值。该命令将重写所有在哈希集中存在的字段。如果 key 指定的哈希集不存在,会创建一个新的哈希集并与 key
* 关联
*
* @param hash
* @param time
*/
public void hmset(String key, Map<String, String> hash, int time) {
call(jedis -> {
jedis.hmset(key, hash);
if (time > 0) {
jedis.expire(key, time);
}
});
}
代码示例来源:origin: com.gitee.qdbp/qdbp-general-biz
/** {@inheritDoc} **/
@Override
public <T> void hmset(String key, String subkey, Map<String, T> map) {
if (map == null || map.isEmpty()) return;
JedisCommands jedis = this.getInstanceByKey(key);
Map<String, String> values = new HashMap<>();
for (Map.Entry<String, T> entry : map.entrySet()) {
values.put(entry.getKey(), serializeValue(entry.getValue()));
}
jedis.hmset(concat(key, subkey), values);
}
代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc
/** {@inheritDoc} **/
@Override
public <T> void hmset(String key, String subkey, Map<String, T> map) {
if (map == null || map.isEmpty()) return;
JedisCommands jedis = this.getInstanceByKey(key);
Map<String, String> values = new HashMap<>();
for (Map.Entry<String, T> entry : map.entrySet()) {
values.put(entry.getKey(), serializeValue(entry.getValue()));
}
jedis.hmset(concat(key, subkey), values);
}
代码示例来源:origin: com.gitee.qdbp/qdbp-general-biz
/** {@inheritDoc} **/
@Override
public <T> void hoset(String key, String subkey, T object) {
Objects.requireNonNull(object, "object");
JedisCommands jedis = this.getInstanceByKey(key);
Map<String, String> map = serializeFields(object);
jedis.hmset(concat(key, subkey), map);
}
代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc
/** {@inheritDoc} **/
@Override
public <T> void hoset(String key, String subkey, T object) {
Objects.requireNonNull(object, "object");
JedisCommands jedis = this.getInstanceByKey(key);
Map<String, String> map = serializeFields(object);
jedis.hmset(concat(key, subkey), map);
}
代码示例来源:origin: com.github.mpusher/mpush-cache
/**
* 设置 key 指定的哈希集中指定字段的值。该命令将重写所有在哈希集中存在的字段。如果 key 指定的哈希集不存在,会创建一个新的哈希集并与 key
* 关联
*
* @param hash
* @param time
*/
public void hmset(String key, Map<String, String> hash, int time) {
call(jedis -> {
jedis.hmset(key, hash);
if (time > 0) {
jedis.expire(key, time);
}
});
}
代码示例来源:origin: com.netflix.spinnaker.clouddriver/clouddriver-core
public void set(String id, JedisTask task) {
String taskId = "task:" + task.getId();
Map<String, String> data = new HashMap<>();
data.put("id", task.getId());
data.put("startTimeMs", Long.toString(task.getStartTimeMs()));
data.put("ownerId", task.getOwnerId());
retry(() -> redisClientDelegate.withCommandsClient(client -> {
client.hmset(taskId, data);
client.expire(taskId, TASK_TTL);
client.sadd(RUNNING_TASK_KEY, id);
}), format("Writing task %s", id));
}
代码示例来源:origin: vakinge/jeesuite-libs
/**
* 设置hash缓存
*
* @param datas
* @return
*/
public boolean set(Map<String, String> datas) {
if(datas == null || datas.isEmpty())return false;
boolean result = false;
try {
result = getJedisCommands(groupName).hmset(key, datas).equals(RESP_OK);
//设置超时时间
if(result)setExpireIfNot(expireTime);
return result;
} finally {
getJedisProvider(groupName).release();
}
}
代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis
@Override
public void updateStatus(ExecutionType type, @Nonnull String id, @Nonnull ExecutionStatus status) {
ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id);
RedisClientDelegate delegate = pair.getRight();
String key = pair.getLeft();
delegate.withCommandsClient(c -> {
Map<String, String> data = new HashMap<>();
data.put("status", status.name());
if (status == ExecutionStatus.RUNNING) {
data.put("canceled", "false");
data.put("startTime", String.valueOf(currentTimeMillis()));
} else if (status.isComplete() && c.hget(key, "startTime") != null) {
data.put("endTime", String.valueOf(currentTimeMillis()));
}
if (status == BUFFERED) {
c.sadd(allBufferedExecutionsKey(type), id);
} else {
c.srem(allBufferedExecutionsKey(type), id);
}
c.hmset(key, data);
});
}
代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis
@Override
public void cancel(ExecutionType type, @Nonnull String id, String user, String reason) {
ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id);
RedisClientDelegate delegate = pair.getRight();
delegate.withCommandsClient(c -> {
Map<String, String> data = new HashMap<>();
data.put("canceled", "true");
if (StringUtils.isNotEmpty(user)) {
data.put("canceledBy", user);
}
if (StringUtils.isNotEmpty(reason)) {
data.put("cancellationReason", reason);
}
ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status"));
if (currentStatus == ExecutionStatus.NOT_STARTED) {
data.put("status", ExecutionStatus.CANCELED.name());
}
c.hmset(pair.getLeft(), data);
c.srem(allBufferedExecutionsKey(type), id);
});
}
代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis
@Override
public void resume(ExecutionType type, @Nonnull String id, String user, boolean ignoreCurrentStatus) {
ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id);
RedisClientDelegate delegate = pair.getRight();
delegate.withCommandsClient(c -> {
ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status"));
if (!ignoreCurrentStatus && currentStatus != ExecutionStatus.PAUSED) {
throw new UnresumablePipelineException(format(
"Unable to resume pipeline that is not PAUSED (executionId: %s, currentStatus: %s)",
id,
currentStatus
));
}
try {
PausedDetails pausedDetails = mapper.readValue(c.hget(pair.getLeft(), "paused"), PausedDetails.class);
pausedDetails.setResumedBy(user);
pausedDetails.setResumeTime(currentTimeMillis());
Map<String, String> data = new HashMap<>();
data.put("paused", mapper.writeValueAsString(pausedDetails));
data.put("status", ExecutionStatus.RUNNING.toString());
c.hmset(pair.getLeft(), data);
c.srem(allBufferedExecutionsKey(type), id);
} catch (IOException e) {
throw new ExecutionSerializationException("Failed converting pausedDetails to json", e);
}
});
}
代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis
@Override
public void pause(ExecutionType type, @Nonnull String id, String user) {
ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id);
RedisClientDelegate delegate = pair.getRight();
delegate.withCommandsClient(c -> {
ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status"));
if (currentStatus != ExecutionStatus.RUNNING) {
throw new UnpausablePipelineException(format(
"Unable to pause pipeline that is not RUNNING (executionId: %s, currentStatus: %s)",
id,
currentStatus
));
}
PausedDetails pausedDetails = new PausedDetails();
pausedDetails.setPausedBy(user);
pausedDetails.setPauseTime(currentTimeMillis());
Map<String, String> data = new HashMap<>();
try {
data.put("paused", mapper.writeValueAsString(pausedDetails));
} catch (JsonProcessingException e) {
throw new ExecutionSerializationException("Failed converting pausedDetails to json", e);
}
data.put("status", ExecutionStatus.PAUSED.toString());
c.hmset(pair.getLeft(), data);
c.srem(allBufferedExecutionsKey(type), id);
});
}
内容来源于网络,如有侵权,请联系作者删除!