Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change storage ttl time from seconds to milliseconds #2822

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/storage/src/base_meta_value_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BaseMetaValue : public InternalValue {
}

uint64_t UpdateVersion() {
int64_t unix_time = rocksdb::Env::Default()->NowMicros();
int64_t unix_time = rocksdb::Env::Default()->NowMicros() / 1000;
AlexStocks marked this conversation as resolved.
Show resolved Hide resolved
if (version_ >= unix_time) {
version_++;
} else {
Expand Down Expand Up @@ -171,7 +171,7 @@ class ParsedBaseMetaValue : public ParsedInternalValue {
}

uint64_t UpdateVersion() {
int64_t unix_time = rocksdb::Env::Default()->NowMicros();
int64_t unix_time = rocksdb::Env::Default()->NowMicros() / 1000;
if (version_ >= static_cast<uint64_t>(unix_time)) {
version_++;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/storage/src/lists_meta_value_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ListsMetaValue : public InternalValue {
}

uint64_t UpdateVersion() {
int64_t unix_time = rocksdb::Env::Default()->NowMicros();
int64_t unix_time = rocksdb::Env::Default()->NowMicros() / 1000;
if (version_ >= static_cast<uint64_t>(unix_time)) {
version_++;
} else {
Expand Down Expand Up @@ -197,7 +197,7 @@ class ParsedListsMetaValue : public ParsedInternalValue {
}

uint64_t UpdateVersion() {
int64_t unix_time = rocksdb::Env::Default()->NowMicros();
int64_t unix_time = rocksdb::Env::Default()->NowMicros() / 1000;
if (version_ >= static_cast<uint64_t>(unix_time)) {
version_++;
} else {
Expand Down
8 changes: 6 additions & 2 deletions src/storage/src/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,9 @@ int64_t Storage::PTTL(const Slice& key) {
int64_t timestamp = 0;
auto& inst = GetDBInstance(key);
Status s = inst->TTL(key, &timestamp);
if (!s.IsNotFound()) {
if (s.ok() || s.IsNotFound()) {
return timestamp;
} else if (!s.IsNotFound()) {
return -3;
}
return timestamp;
Expand All @@ -1482,7 +1484,9 @@ int64_t Storage::TTL(const Slice& key) {
int64_t timestamp = 0;
auto& inst = GetDBInstance(key);
Status s = inst->TTL(key, &timestamp);
if (!s.IsNotFound()) {
if (s.ok() || s.IsNotFound()) {
return timestamp > 0 ? timestamp / 1000 : timestamp;
} else if (!s.IsNotFound()) {
return -3;
}
return timestamp > 0 ? timestamp / 1000 : timestamp;
Expand Down
Loading