Skip to content

Commit

Permalink
Merge pull request #1611 from AYue-94/fix/heartbeat_redis_setex
Browse files Browse the repository at this point in the history
fix: store heartbeat use redis setex with wrong timeunit
  • Loading branch information
Sherlockhan authored Sep 3, 2024
2 parents a3abf86 + 793e025 commit dc5b997
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean addEvent(Event event) {

@Override
public boolean addInstanceMeta(InstanceMeta instanceMeta) {
redisOperation.setex(instanceMeta.getMetaHash(), backendConfig.getHeartbeatEffectiveTime(),
redisOperation.psetex(instanceMeta.getMetaHash(), backendConfig.getHeartbeatEffectiveTime(),
JSONObject.toJSONString(instanceMeta));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public String setex(String key, long seconds, String value) {
return jedisCluster.setex(key, seconds, value);
}

@Override
public String psetex(String key, long milliseconds, String value) {
return jedisCluster.psetex(key, milliseconds, value);
}

@Override
public long hset(String key, String field, String value) {
return jedisCluster.hset(key, field, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public interface RedisOperation {
*/
String setex(String key, long seconds, String value);

/**
* Store key values and specify expiration time
*
* @param key Data stored in Redis key
* @param milliseconds expiration time
* @param value Stored values
* @return Return execution result
*/
String psetex(String key, long milliseconds, String value);

/**
* Set the specified hash field to the specified value.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public String setex(String key, long seconds, String value) {
}
}

@Override
public String psetex(String key, long milliseconds, String value) {
try (Jedis jedis = jedisPool.getResource()) {
return jedis.psetex(key, milliseconds, value);
}
}

@Override
public long hset(String key, String field, String value) {
try (Jedis jedis = jedisPool.getResource()) {
Expand Down

0 comments on commit dc5b997

Please sign in to comment.