-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Describe the enhancement requested
KeyToolkit is used internally according to the comment. It looks more like a mere aggregate. I suggest redefine it as a struct and change existing member functions to free functions, which can be implemented by the public interfaces of existing member variables. The only exception which may introduce invariants is the first part of KeyToolket::RotateMasterKeys(),
arrow/cpp/src/parquet/encryption/key_toolkit.cc
Lines 54 to 61 in 6e84d99
| const auto now = internal::CurrentTimePoint(); | |
| auto lock = last_cache_clean_for_key_rotation_time_mutex_.Lock(); | |
| if (now > last_cache_clean_for_key_rotation_time_ + | |
| std::chrono::duration<double>(kCacheCleanPeriodForKeyRotation)) { | |
| kek_write_cache_per_token().Clear(); | |
| last_cache_clean_for_key_rotation_time_ = now; | |
| } | |
| lock.Unlock(); |
However, TwoLevelCacheWithExpiration (the object return by kek_write_cache_per_token() in the code above) has nearly identical logic,
arrow/cpp/src/parquet/encryption/two_level_cache_with_expiration.h
Lines 114 to 124 in 6e84d99
| void CheckCacheForExpiredTokens(double cache_cleanup_period_seconds) { | |
| auto lock = mutex_.Lock(); | |
| const auto now = internal::CurrentTimePoint(); | |
| if (now > (last_cache_cleanup_timestamp_ + | |
| std::chrono::duration<double>(cache_cleanup_period_seconds))) { | |
| RemoveExpiredEntriesNoMutex(); | |
| last_cache_cleanup_timestamp_ = | |
| now + std::chrono::duration<double>(cache_cleanup_period_seconds); | |
| } | |
| } |
except that the timestamp is set to now + cache_cleanup_period_seconds, which looks like a bug.
The same change can be applied to KeyWithMasterId.
I'll work on it if this gets approved.
Component(s)
C++