Skip to content

Commit 1513cf9

Browse files
committed
fix SETEX replication does not work
1 parent 1b0990e commit 1513cf9

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/pika_kv.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ std::string SetexCmd::ToRedisProtocol() {
887887
RedisAppendContent(content, key_);
888888
// time_stamp
889889
char buf[100];
890-
auto time_stamp = time(nullptr) + ttl_sec_;
890+
int64_t time_stamp = static_cast<int64_t>(::time(nullptr)) + ttl_sec_;
891891
pstd::ll2string(buf, 100, time_stamp);
892892
std::string at(buf);
893893
RedisAppendLenUint64(content, at.size(), "$");
@@ -945,8 +945,9 @@ std::string PsetexCmd::ToRedisProtocol() {
945945
RedisAppendLenUint64(content, key_.size(), "$");
946946
RedisAppendContent(content, key_);
947947
// time_stamp
948+
int64_t expire_at_ms = pstd::NowMillis() + ttl_millsec;
949+
int64_t time_stamp = expire_at_ms / 1000;
948950
char buf[100];
949-
auto time_stamp = pstd::NowMillis() + ttl_millsec;
950951
pstd::ll2string(buf, 100, time_stamp);
951952
std::string at(buf);
952953
RedisAppendLenUint64(content, at.size(), "$");

0 commit comments

Comments
 (0)