This commit is contained in:
20
rediska/cache/BaseItemMetadata.cpp
vendored
Normal file
20
rediska/cache/BaseItemMetadata.cpp
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "BaseItemMetadata.hpp"
|
||||
|
||||
namespace cache {
|
||||
BaseItemMetadata::BaseItemMetadata(TTL ttl) : ttl_(ttl) {
|
||||
resetExpirationTime();
|
||||
}
|
||||
|
||||
void BaseItemMetadata::updateTTL(TTL ttl) {
|
||||
ttl_ = ttl;
|
||||
resetExpirationTime();
|
||||
}
|
||||
|
||||
bool BaseItemMetadata::isExpired() const {
|
||||
return expirationTime_ < std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
void BaseItemMetadata::resetExpirationTime() {
|
||||
expirationTime_ = std::chrono::steady_clock::now() + std::chrono::seconds(ttl_);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user