|  | Kea 3.1.0
    | 
ExpressionCache stores expressions per subnet. More...
#include <expression_cache.h>
| Public Member Functions | |
| ExpressionCache () | |
| Constructor. | |
| virtual | ~ExpressionCache () | 
| Destructor. | |
| void | cacheExpression (const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression) | 
| Adds (or replaces) the expression for a given subnet to the cache. | |
| void | clear () | 
| Delete all the entries in the cache. | |
| bool | findExpression (const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression) | 
| Fetches the expression for a given subnet. | |
| boost::posix_time::ptime | getLastFlushTime () | 
| Returns the last time the cache was flushed (or the time it was created if it has never been flushed). | |
| dhcp::ExpressionPtr | parseAndCacheExpression (const dhcp::SubnetID &subnet_id, const std::string &expression_str, uint32_t family) | 
| Parses an expression string and caches for the given subnet. | |
| size_t | size () | 
| Returns number of entries in the cache. | |
| Public Member Functions inherited from isc::data::BaseStampedElement | |
| BaseStampedElement () | |
| Constructor. | |
| uint64_t | getId () const | 
| Returns element's database identifier. | |
| boost::posix_time::ptime | getModificationTime () const | 
| Returns timestamp. | |
| void | setId (const uint64_t id) | 
| Sets element's database identifier. | |
| void | setModificationTime (const boost::posix_time::ptime ×tamp) | 
| Sets timestamp to the explicitly provided value. | |
| void | updateModificationTime () | 
| Sets timestamp to the current time. | |
| Additional Inherited Members | |
| Protected Attributes inherited from isc::data::BaseStampedElement | |
| uint64_t | id_ | 
| Database identifier of the configuration element. | |
| boost::posix_time::ptime | timestamp_ | 
| Holds timestamp value. | |
ExpressionCache stores expressions per subnet.
For every subnet (lazy init) we store:
Each time we clear the cache we update the modification time.
When presented with a subnet:
entry exists: subnet mod time >= last flush cache is stale flush it cache it
subnet mod time < last flush use it
Definition at line 54 of file expression_cache.h.
| 
 | inline | 
Constructor.
Definition at line 57 of file expression_cache.h.
| 
 | inlinevirtual | 
Destructor.
Definition at line 61 of file expression_cache.h.
| void isc::ddns_tuning::ExpressionCache::cacheExpression | ( | const dhcp::SubnetID & | subnet_id, | 
| dhcp::ExpressionPtr & | expression ) | 
Adds (or replaces) the expression for a given subnet to the cache.
| subnet_id | ID of the subnet for which the expression is desired. | 
| expression | pointer to the expression to store. This may be an empty pointer. | 
Definition at line 68 of file expression_cache.cc.
References isc::util::MultiThreadingMgr::instance().
Referenced by parseAndCacheExpression().
| void isc::ddns_tuning::ExpressionCache::clear | ( | ) | 
Delete all the entries in the cache.
Definition at line 78 of file expression_cache.cc.
References isc::util::MultiThreadingMgr::instance(), and isc::data::BaseStampedElement::updateModificationTime().
| bool isc::ddns_tuning::ExpressionCache::findExpression | ( | const dhcp::SubnetID & | subnet_id, | 
| dhcp::ExpressionPtr & | expression ) | 
Fetches the expression for a given subnet.
| subnet_id | ID of the subnet for which the expression is desired. | |
| [out] | expression | a reference to a pointer in which to store the expression if found. If there is no entry for the subnet, it will be set to an empty pointer. | 
Definition at line 23 of file expression_cache.cc.
References isc::util::MultiThreadingMgr::instance().
| boost::posix_time::ptime isc::ddns_tuning::ExpressionCache::getLastFlushTime | ( | ) | 
Returns the last time the cache was flushed (or the time it was created if it has never been flushed).
Definition at line 106 of file expression_cache.cc.
References isc::data::BaseStampedElement::getModificationTime(), and isc::util::MultiThreadingMgr::instance().
| ExpressionPtr isc::ddns_tuning::ExpressionCache::parseAndCacheExpression | ( | const dhcp::SubnetID & | subnet_id, | 
| const std::string & | expression_str, | ||
| uint32_t | family ) | 
Parses an expression string and caches for the given subnet.
| subnet_id | ID of the subnet for which the expression is desired. | 
| expression_str | string containing the expression to parse and cache. | 
| family | protocol family (AF_INET or AF_INET6) of the subnet/expression. | 
| BadValue | if an error occurred during expression parsing. | 
Definition at line 45 of file expression_cache.cc.
References cacheExpression(), isc::eval::EvalContext::expression_, isc_throw, isc::eval::EvalContext::PARSER_STRING, isc::eval::EvalContext::parseString(), isc::dhcp::Option::V4, and isc::dhcp::Option::V6.
| size_t isc::ddns_tuning::ExpressionCache::size | ( | ) | 
Returns number of entries in the cache.
Definition at line 96 of file expression_cache.cc.
References isc::util::MultiThreadingMgr::instance().