MCPcopy Create free account
hub / github.com/L1yp/van-app / execute

Method execute

src/main/java/com/l1yp/base/RedisTool.java:42–58  ·  view source on GitHub ↗
(RedisOperations operations)

Source from the content-addressed store, hash-verified

40 List<Object> txResults = template.execute(new SessionCallback<List<Object>>() {
41
42 @SuppressWarnings("unchecked")
43 @Override
44 public List<Object> execute(RedisOperations operations) throws DataAccessException {
45 operations.multi(); // 开始 redis 事务
46
47 operations.opsForHash().put(key, field, Objects.requireNonNull(JsonTool.toJson(val)));
48
49 Duration expireTime = key.getExpireTime();
50 long expireAt = key.getExpireAt();
51 if (expireTime == null) {
52 operations.expireAt(key, Instant.ofEpochSecond(expireAt));
53 } else {
54 operations.expire(key, expireTime);
55 }
56
57 return operations.exec(); // 提交redis 事务
58 }
59 });
60 if (txResults != null && txResults.size() == 2) {
61 return txResults.get(0) == Boolean.TRUE && txResults.get(1) == Boolean.TRUE;

Callers 4

hsetMethod · 0.80
hmsetMethod · 0.80
setMethod · 0.80
msetMethod · 0.80

Calls 6

toJsonMethod · 0.95
getExpireTimeMethod · 0.95
getExpireAtMethod · 0.95
putMethod · 0.80
setMethod · 0.80
getKeyMethod · 0.45

Tested by

no test coverage detected