Added get_data_expires function to both Perl and Lua to retrieve DataBucket expire time

This commit is contained in:
Matt Hogan
2018-10-19 19:37:25 -04:00
parent 9f039b47e9
commit 88debae660
4 changed files with 45 additions and 0 deletions
+25
View File
@@ -76,6 +76,31 @@ std::string DataBucket::GetData(std::string bucket_key) {
return std::string(row[0]);
}
/**
* Retrieves data expires time via bucket_name as key
* @param bucket_key
* @return
*/
std::string DataBucket::GetDataExpires(std::string bucket_key) {
std::string query = StringFormat(
"SELECT `expires` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
bucket_key.c_str(),
(long long) std::time(nullptr)
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return std::string();
}
if (results.RowCount() != 1)
return std::string();
auto row = results.begin();
return std::string(row[0]);
}
/**
* Checks for bucket existence by bucket_name key
* @param bucket_key