mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 11:48:37 +00:00
Added get_data_expires function to both Perl and Lua to retrieve DataBucket expire time
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user