mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
add dense_set.SetExpiryTime in preparation for fieldexpire (#3780)
* feat: add DenseSet::IteratorBase::SetExpiryTime This commit is in preparation for adding FIELDEXPIRE and HEXPIRE. * fix: 0 is a valid input for MakeSetSds
This commit is contained in:
parent
e3214cb603
commit
2ab480e160
12 changed files with 115 additions and 38 deletions
|
@ -46,6 +46,17 @@ DenseSet::IteratorBase::IteratorBase(const DenseSet* owner, bool is_end)
|
|||
}
|
||||
}
|
||||
|
||||
void DenseSet::IteratorBase::SetExpiryTime(uint32_t ttl_sec) {
|
||||
if (!HasExpiry()) {
|
||||
auto src = curr_entry_->GetObject();
|
||||
void* new_obj = owner_->ObjectClone(src, false, true);
|
||||
curr_entry_->SetObject(new_obj);
|
||||
curr_entry_->SetTtl(true);
|
||||
owner_->ObjDelete(src, false);
|
||||
}
|
||||
owner_->ObjUpdateExpireTime(curr_entry_->GetObject(), ttl_sec);
|
||||
}
|
||||
|
||||
void DenseSet::IteratorBase::Advance() {
|
||||
bool step_link = false;
|
||||
DCHECK(curr_entry_);
|
||||
|
@ -211,7 +222,7 @@ void DenseSet::CloneBatch(unsigned len, CloneItem* items, DenseSet* other) const
|
|||
auto& src = items[i];
|
||||
if (src.obj) {
|
||||
// The majority of the CPU is spent in this block.
|
||||
void* new_obj = other->ObjectClone(src.obj, src.has_ttl);
|
||||
void* new_obj = other->ObjectClone(src.obj, src.has_ttl, false);
|
||||
uint64_t hash = Hash(src.obj, 0);
|
||||
other->AddUnique(new_obj, src.has_ttl, hash);
|
||||
src.obj = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue