Public Member Functions | Protected Member Functions | Private Attributes | List of all members
novadaq::TimedCachePolicy Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-06/NovaDAQUtilities/cxx/include/TimedCachePolicy.h"

Inheritance diagram for novadaq::TimedCachePolicy:
novadaq::CachePolicy

Public Member Functions

 TimedCachePolicy (int timeoutInMinutes)
 
 ~TimedCachePolicy ()
 
void cacheUpdated ()
 
bool isExpired ()
 

Protected Member Functions

void _markAsUpdated ()
 
bool _checkIfExpired ()
 

Private Attributes

time_t _timeoutInSeconds
 
time_t _lastUpdateTime
 

Detailed Description

A cache expiration policy based on a time interval.

Author
Kurt Biery
Version
Revision
1.2.34.1
Date
2019/09/27 00:07:20

Definition at line 16 of file TimedCachePolicy.h.

Constructor & Destructor Documentation

novadaq::TimedCachePolicy::TimedCachePolicy ( int  timeoutInMinutes)
explicit

Constructor.

Parameters
timeoutInMinutesThe time, in minutes, after which the policy will report that a cache has expired.

Definition at line 11 of file TimedCachePolicy.cpp.

11  :
12  _timeoutInSeconds(timeoutInMinutes * 60) {}
novadaq::TimedCachePolicy::~TimedCachePolicy ( )
inline

Definition at line 22 of file TimedCachePolicy.h.

References _checkIfExpired(), and _markAsUpdated().

22 {};

Member Function Documentation

bool novadaq::TimedCachePolicy::_checkIfExpired ( )
protectedvirtual

Tests if the associated cache has expired based on the criteria in the policy.

Returns
true if the cache has expired, false if not.

Reimplemented from novadaq::CachePolicy.

Definition at line 28 of file TimedCachePolicy.cpp.

References _lastUpdateTime, _timeoutInSeconds, and recentWatchdog::now.

Referenced by ~TimedCachePolicy().

28  {
29  time_t now = time(0);
30  time_t cacheAge = now - _lastUpdateTime;
31  return (cacheAge >= _timeoutInSeconds);
32 }
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
void novadaq::TimedCachePolicy::_markAsUpdated ( )
protectedvirtual

Tells the policy that a cache update was done. This is used to reset the state of the policy to "unexpired" after an update.

Reimplemented from novadaq::CachePolicy.

Definition at line 18 of file TimedCachePolicy.cpp.

References _lastUpdateTime.

Referenced by ~TimedCachePolicy().

18  {
19  _lastUpdateTime = time(0);
20 }
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
void novadaq::CachePolicy::cacheUpdated ( )
inherited

Tells the policy that a cache update was done. This is used to reset the state of the policy to "unexpired" after an update.

Definition at line 9 of file CachePolicy.cpp.

References novadaq::CachePolicy::_markAsUpdated().

Referenced by novadaq::Cache::_reloadIfNeeded(), and novadaq::CachePolicy::~CachePolicy().

9  {
11 }
virtual void _markAsUpdated()
Definition: CachePolicy.cpp:27
bool novadaq::CachePolicy::isExpired ( )
inherited

Tests if the associated cache has expired based on the criteria in the policy.

Returns
true if the cache has expired, false if not.

Definition at line 19 of file CachePolicy.cpp.

References novadaq::CachePolicy::_checkIfExpired().

Referenced by novadaq::Cache::_reloadIfNeeded(), and novadaq::CachePolicy::~CachePolicy().

19  {
20  return _checkIfExpired();
21 }
virtual bool _checkIfExpired()
Definition: CachePolicy.cpp:38

Member Data Documentation

time_t novadaq::TimedCachePolicy::_lastUpdateTime
private

Definition at line 33 of file TimedCachePolicy.h.

Referenced by _checkIfExpired(), and _markAsUpdated().

time_t novadaq::TimedCachePolicy::_timeoutInSeconds
private

Definition at line 32 of file TimedCachePolicy.h.

Referenced by _checkIfExpired().


The documentation for this class was generated from the following files: