jedisCommand.rpush(key, value); break;
public void addResultObjects(List<Object> objects, JedisTask task) { String resultId = "taskResult:" + task.getId(); String[] values = objects.stream() .map(o -> { try { return mapper.writeValueAsString(o); } catch (JsonProcessingException e) { throw new RuntimeException("Failed to convert object to string", e); } }) .collect(Collectors.toList()) .toArray(new String[objects.size()]); log.debug("Adding results to task {} (results: {})", task.getId(), values); retry(() -> redisClientDelegate.withCommandsClient(client -> { client.rpush(resultId, values); client.expire(resultId, TASK_TTL); }), format("Adding results to task %s", task.getId())); }
public boolean rpush(String...strings) { try { boolean result = getJedisCommands(groupName).rpush(key, strings) == 1; //设置超时时间 if(result)setExpireIfNot(expireTime); return result; } finally { getJedisProvider(groupName).release(); } }
public void addToHistory(DefaultTaskStatus status, JedisTask task) { String historyId = "taskHistory:" + task.getId(); Map<String, String> data = new HashMap<>(); data.put("phase", status.getPhase()); data.put("status", status.getStatus()); data.put("state", status.getState().toString()); String hist; try { hist = mapper.writeValueAsString(data); } catch (JsonProcessingException e) { throw new RuntimeException("Failed converting task history to json", e); } retry(() -> redisClientDelegate.withCommandsClient(client -> { client.rpush(historyId, hist); client.expire(historyId, TASK_TTL); if (status.isCompleted()) { client.srem(RUNNING_TASK_KEY, task.getId()); } }), format("Adding status history to task %s: %s", task.getId(), status)); }