mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
SQLite: Reset expiration time on overwrite
This commit is contained in:
parent
5daa83bfa4
commit
fd7259f436
3 changed files with 31 additions and 1 deletions
|
@ -186,7 +186,7 @@ OperationResult SQLite::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
db),
|
||||
std::make_pair(util::
|
||||
fmt("insert into %s (key_str, value_str, expire_time) values(?, ?, ?) ON CONFLICT(key_str) "
|
||||
"DO UPDATE SET value_str=?",
|
||||
"DO UPDATE SET value_str=?, expire_time=?",
|
||||
table_name.c_str()),
|
||||
db),
|
||||
std::make_pair(util::fmt("select value_str from %s where key_str=?", table_name.c_str()), db),
|
||||
|
@ -318,6 +318,12 @@ OperationResult SQLite::DoPut(ResultCallback* cb, ValPtr key, ValPtr value, bool
|
|||
res.code != ReturnCode::SUCCESS ) {
|
||||
return res;
|
||||
}
|
||||
|
||||
// This duplicates the above binding, but it's to overwrite the expiration time on the entry.
|
||||
if ( auto res = CheckError(sqlite3_bind_double(stmt.get(), 5, expiration_time));
|
||||
res.code != ReturnCode::SUCCESS ) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return Step(stmt.get(), false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue