@@ -72,8 +72,6 @@ constexpr size_t kMaxValueSize = 1024; // 1024 byte
72
72
// * 4 bytes for fingerprint seed
73
73
constexpr size_t kFileHeaderSize = 12 ;
74
74
75
- constexpr uint64_t k62DaysInSec = 62 * 24 * 60 * 60 ;
76
-
77
75
uint64_t GetFP (const char * ptr) { return LoadUnaligned<uint64_t >(ptr); }
78
76
79
77
uint32_t GetTimeStamp (const char * ptr) {
@@ -97,11 +95,6 @@ void Update(char* ptr, uint64_t fp, const char* value, size_t value_size) {
97
95
std::copy_n (value, value_size, ptr);
98
96
}
99
97
100
- bool IsOlderThan62Days (uint64_t timestamp) {
101
- const uint64_t now = absl::ToUnixSeconds (Clock::GetAbslTime ());
102
- return (timestamp + k62DaysInSec < now);
103
- }
104
-
105
98
class CompareByTimeStamp {
106
99
public:
107
100
bool operator ()(const char * a, const char * b) const {
@@ -382,16 +375,10 @@ bool LruStorage::Open(char* ptr, size_t ptr_size) {
382
375
next_item_ = (next != nullptr ) ? next : end_;
383
376
DCHECK_LE (next_item_, end_);
384
377
385
- // At the time file is opened, perform clean up.
386
- DeleteElementsUntouchedFor62Days ();
387
-
388
378
return true ;
389
379
}
390
380
391
381
void LruStorage::Close () {
392
- // Perform clean up before closing the file.
393
- DeleteElementsUntouchedFor62Days ();
394
-
395
382
filename_.clear ();
396
383
mmap_.Close ();
397
384
lru_list_.clear ();
@@ -406,9 +393,6 @@ const char* absl_nullable LruStorage::Lookup(const absl::string_view key,
406
393
return nullptr ;
407
394
}
408
395
const uint32_t timestamp = GetTimeStamp (*it->second );
409
- if (IsOlderThan62Days (timestamp)) {
410
- return nullptr ;
411
- }
412
396
*last_access_time = timestamp;
413
397
return GetValue (*it->second );
414
398
}
@@ -419,10 +403,6 @@ void LruStorage::GetAllValues(std::vector<std::string>* values) const {
419
403
// Iterate data from the most recently used element to the least recently used
420
404
// element.
421
405
for (const char * ptr : lru_list_) {
422
- const uint32_t timestamp = GetTimeStamp (ptr);
423
- if (IsOlderThan62Days (timestamp)) {
424
- break ;
425
- }
426
406
// Default constructor of string is not applicable
427
407
// because value's size() must return value_size_.
428
408
DCHECK (ptr);
@@ -436,10 +416,6 @@ bool LruStorage::Touch(const absl::string_view key) {
436
416
if (it == lru_map_.end ()) {
437
417
return false ;
438
418
}
439
- const uint32_t timestamp = GetTimeStamp (*it->second );
440
- if (IsOlderThan62Days (timestamp)) {
441
- return false ;
442
- }
443
419
Update (*it->second );
444
420
// Move the node pointed to by it->second to the front.
445
421
lru_list_.splice (lru_list_.begin (), lru_list_, it->second );
@@ -566,13 +542,6 @@ int LruStorage::DeleteElementsBefore(uint32_t timestamp) {
566
542
return num_deleted;
567
543
}
568
544
569
- int LruStorage::DeleteElementsUntouchedFor62Days () {
570
- const uint64_t now = absl::ToUnixSeconds (Clock::GetAbslTime ());
571
- const uint32_t timestamp =
572
- static_cast <uint32_t >((now > k62DaysInSec) ? now - k62DaysInSec : 0 );
573
- return DeleteElementsBefore (timestamp);
574
- }
575
-
576
545
void LruStorage::Write (size_t i, uint64_t fp, const absl::string_view value,
577
546
uint32_t last_access_time) {
578
547
DCHECK_LT (i, size_);
0 commit comments