Kea 3.1.1
isc::ddns_tuning::ExpressionCache Class Reference

ExpressionCache stores expressions per subnet. More...

#include <expression_cache.h>

+ Inheritance diagram for isc::ddns_tuning::ExpressionCache:

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 &timestamp)
 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.
 

Detailed Description

ExpressionCache stores expressions per subnet.

For every subnet (lazy init) we store:

  1. subnet id
  2. expression pointer where:
    • empty pointer means that subnet does not define an expression
    • empty expression means that subnet overrides a global expression with no expression
    • non-empty means subnet overrides a global expression with an expression

Each time we clear the cache we update the modification time.

When presented with a subnet:

  1. no cache entry: cache it
  2. 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.

Constructor & Destructor Documentation

◆ ExpressionCache()

isc::ddns_tuning::ExpressionCache::ExpressionCache ( )
inline

Constructor.

Definition at line 57 of file expression_cache.h.

◆ ~ExpressionCache()

virtual isc::ddns_tuning::ExpressionCache::~ExpressionCache ( )
inlinevirtual

Destructor.

Definition at line 61 of file expression_cache.h.

Member Function Documentation

◆ cacheExpression()

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.

Parameters
subnet_idID of the subnet for which the expression is desired.
expressionpointer 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().

+ Here is the call graph for this function:

◆ clear()

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().

+ Here is the call graph for this function:

◆ findExpression()

bool isc::ddns_tuning::ExpressionCache::findExpression ( const dhcp::SubnetID & subnet_id,
dhcp::ExpressionPtr & expression )

Fetches the expression for a given subnet.

Parameters
subnet_idID of the subnet for which the expression is desired.
[out]expressiona 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.
Returns
True if an entry for subnet was found, false otherwise. This allows callers to distinguish between unknown subnets (entries that do not exist) and subnets that are known but do not define an expression.

Definition at line 23 of file expression_cache.cc.

References isc::util::MultiThreadingMgr::instance().

+ Here is the call graph for this function:

◆ getLastFlushTime()

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().

+ Here is the call graph for this function:

◆ parseAndCacheExpression()

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.

Parameters
subnet_idID of the subnet for which the expression is desired.
expression_strstring containing the expression to parse and cache.
familyprotocol family (AF_INET or AF_INET6) of the subnet/expression.
Returns
pointer to the parsed expression.
Exceptions
BadValueif 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.

+ Here is the call graph for this function:

◆ size()

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().

+ Here is the call graph for this function:

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