2022-01-13 21:47:04 +08:00
|
|
|
// Copyright 2022, Roman Gershman. All rights reserved.
|
2021-12-20 17:42:55 +08:00
|
|
|
// See LICENSE for licensing terms.
|
|
|
|
//
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-01-20 18:26:10 +08:00
|
|
|
#include "server/detail/table.h"
|
2021-12-20 17:42:55 +08:00
|
|
|
|
2022-01-13 21:47:04 +08:00
|
|
|
namespace dfly {
|
2021-12-20 17:42:55 +08:00
|
|
|
|
2022-01-20 18:26:10 +08:00
|
|
|
using PrimeKey = detail::PrimeKey;
|
|
|
|
using PrimeValue = detail::PrimeValue;
|
2022-01-20 11:25:43 +08:00
|
|
|
|
2022-01-20 18:26:10 +08:00
|
|
|
using PrimeTable = DashTable<PrimeKey, PrimeValue, detail::PrimeTablePolicy>;
|
|
|
|
using ExpireTable = DashTable<PrimeKey, uint64_t, detail::ExpireTablePolicy>;
|
2021-12-20 17:42:55 +08:00
|
|
|
|
|
|
|
/// Iterators are invalidated when new keys are added to the table or some entries are deleted.
|
|
|
|
/// Iterators are still valid if a different entry in the table was mutated.
|
2022-01-20 18:26:10 +08:00
|
|
|
using MainIterator = PrimeTable::iterator;
|
2021-12-20 17:42:55 +08:00
|
|
|
using ExpireIterator = ExpireTable::iterator;
|
|
|
|
|
2022-01-04 21:11:37 +08:00
|
|
|
inline bool IsValid(MainIterator it) {
|
2022-01-20 18:26:10 +08:00
|
|
|
return !it.is_done();
|
2022-01-04 21:11:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsValid(ExpireIterator it) {
|
2022-01-20 11:25:43 +08:00
|
|
|
return !it.is_done();
|
2022-01-04 21:11:37 +08:00
|
|
|
}
|
|
|
|
|
2021-12-20 17:42:55 +08:00
|
|
|
} // namespace dfly
|