Skip to content

Commit

Permalink
support ttl in ms (#5430)
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 authored Mar 23, 2023
1 parent 527c9b0 commit 913cc8b
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit 913cc8b

Please sign in to comment.