Code simplifications.

1. Sets do not use anymore redis encoding constants in our codebase.
2. rdb_save serializes now expiry information as well.
3. db_slice provides a simplified api to translate from absolute time to ExpirePeriod.
4. common_types.h is renamed to common.h. cached memory usage variables are moved there.
This commit is contained in:
Roman Gershman 2022-04-07 11:01:10 +03:00
parent fa70267729
commit d03cea5e36
29 changed files with 205 additions and 196 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2021, Roman Gershman. All rights reserved.
// Copyright 2022, Roman Gershman. All rights reserved.
// See LICENSE for licensing terms.
//
@ -9,7 +9,7 @@
#include "core/intent_lock.h"
#include "facade/op_status.h"
#include "server/common_types.h"
#include "server/common.h"
#include "server/table.h"
namespace util {
@ -101,8 +101,13 @@ class DbSlice {
memory_budget_ = budget;
}
uint64_t expire_base() const {
return expire_base_[0];
// returns absolute time of the expiration.
uint64_t ExpireTime(ExpireIterator it) const {
return it.is_done() ? 0 : expire_base_[0] + it->second.duration();
}
ExpirePeriod FromAbsoluteTime(uint64_t time_ms) const {
return ExpirePeriod{time_ms - expire_base_[0]};
}
// returns wall clock in millis as it has been set via UpdateExpireClock.