Kea 3.1.1
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
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
55public:
57 ExpressionCache() : expressions_() {
58 }
59
61 virtual ~ExpressionCache() {
62 }
63
73 bool findExpression(const dhcp::SubnetID& subnet_id,
74 dhcp::ExpressionPtr& expression);
75
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
This class represents configuration element which is associated with database identifier and the modi...
void clear()
Delete all the entries in the cache.
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.
void cacheExpression(const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression)
Adds (or replaces) the expression for a given subnet to the cache.
size_t size()
Returns number of entries in the cache.
virtual ~ExpressionCache()
Destructor.
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)...
bool findExpression(const dhcp::SubnetID &subnet_id, dhcp::ExpressionPtr &expression)
Fetches the expression for a given subnet.
boost::shared_ptr< Expression > ExpressionPtr
Definition token.h:31
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
Defines the logger used by the top-level component of kea-lfc.