Kea: expression_cache.h Source File

| Kea 3.2.0-git

expression_cache.h
Go to the documentation of this file.
1// Copyright (C) 2022-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef EXPRESSION_CACHE_H
8#define EXPRESSION_CACHE_H
9
10#include <cc/base_stamped_element.h>
11#include <cc/data.h>
12#include <eval/evaluate.h>
13#include <eval/token.h>
14#include <dhcpsrv/subnet.h>
15
16#include <boost/algorithm/string/split.hpp>
17#include <boost/algorithm/string/classification.hpp>
18
19#include <map>
20#include <mutex>
21#include <string>
22
23namespace isc {
24namespace ddns_tuning {
25
54 class ExpressionCache : public data::BaseStampedElement {
55public:
57 ExpressionCache() : expressions_() {
58 }
59
61 virtual ~ExpressionCache() {
62 }
63
73 bool findExpression(const dhcp::SubnetID& subnet_id,
74 dhcp::ExpressionPtr& expression);
75
83 dhcp::ExpressionPtr parseAndCacheExpression(const dhcp::SubnetID& subnet_id,
84 const std::string& expression_str,
85 uint32_t family);
86
92 void cacheExpression(const dhcp::SubnetID& subnet_id,
93 dhcp::ExpressionPtr& expression);
94
96 void clear();
97
99 size_t size();
100
103 boost::posix_time::ptime getLastFlushTime();
104
105private:
117 bool findExpressionInternal(const dhcp::SubnetID& subnet_id, dhcp::ExpressionPtr& expression) const;
118
121 std::map<dhcp::SubnetID, dhcp::ExpressionPtr> expressions_;
122
124 std::mutex mutex_;
125};
126
127} // end of namespace ddns_tuning
128} // end of namespace isc
129#endif
base_stamped_element.h
isc::data::BaseStampedElement
This class represents configuration element which is associated with database identifier and the modi...
Definition base_stamped_element.h:30
isc::ddns_tuning::ExpressionCache::clear
void clear()
Delete all the entries in the cache.
Definition expression_cache.cc:78
isc::ddns_tuning::ExpressionCache::parseAndCacheExpression
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.
Definition expression_cache.cc:45
isc::ddns_tuning::ExpressionCache::cacheExpression
void cacheExpression(const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression)
Adds (or replaces) the expression for a given subnet to the cache.
Definition expression_cache.cc:68
isc::ddns_tuning::ExpressionCache::size
size_t size()
Returns number of entries in the cache.
Definition expression_cache.cc:96
isc::ddns_tuning::ExpressionCache::~ExpressionCache
virtual ~ExpressionCache()
Destructor.
Definition expression_cache.h:61
isc::ddns_tuning::ExpressionCache::ExpressionCache
ExpressionCache()
Constructor.
Definition expression_cache.h:57
isc::ddns_tuning::ExpressionCache::getLastFlushTime
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)...
Definition expression_cache.cc:106
isc::ddns_tuning::ExpressionCache::findExpression
bool findExpression(const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression)
Fetches the expression for a given subnet.
Definition expression_cache.cc:23
data.h
evaluate.h
isc::ddns_tuning
Definition ddns_tuning.cc:27
isc::dhcp::ExpressionPtr
boost::shared_ptr< Expression > ExpressionPtr
Definition token.h:31
isc::dhcp::SubnetID
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
subnet.h
token.h