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

support ttl in ms #5430

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
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
14 changes: 13 additions & 1 deletion src/storage/CommonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include "storage/exec/QueryUtils.h"

DEFINE_bool(ttl_use_ms,
false,
"whether the ttl is configured as milliseconds instead of default seconds");

namespace nebula {
namespace storage {

Expand All @@ -31,7 +35,15 @@ bool CommonUtils::checkDataExpiredForTTL(const meta::NebulaSchemaProvider* schem
ftype != nebula::cpp2::PropertyType::INT64) {
return false;
}
auto now = std::time(NULL);

int64_t now;
// The unit of ttl expiration unit is controlled by user, we just use a gflag here.
if (!FLAGS_ttl_use_ms) {
now = std::time(nullptr);
} else {
auto t = std::chrono::system_clock::now();
now = std::chrono::duration_cast<std::chrono::milliseconds>(t.time_since_epoch()).count();
}

// if the value is not INT type (sush as NULL), it will never expire.
// TODO (sky) : DateTime
Expand Down