Kea 3.1.1
config_cache.h
Go to the documentation of this file.
1// Copyright (C) 2023-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 CONFIG_CACHE_H
8#define CONFIG_CACHE_H
9
10#include <ping_check_config.h>
12#include <cc/data.h>
13#include <dhcpsrv/subnet.h>
14
15#include <map>
16#include <mutex>
17
18namespace isc {
19namespace ping_check {
20
51public:
53 ConfigCache() : configs_(), global_config_(new PingCheckConfig()), mutex_(new std::mutex) {
54 }
55
57 virtual ~ConfigCache() = default;
58
69 bool findConfig(const dhcp::SubnetID& subnet_id,
71
80 data::ConstElementPtr& user_context);
81
87 void cacheConfig(const dhcp::SubnetID& subnet_id,
89
91 void flush();
92
96 size_t size();
97
102 boost::posix_time::ptime getLastFlushTime();
103
108
113
114private:
127 bool findConfigInternal(const dhcp::SubnetID& subnet_id,
129
132 std::map<dhcp::SubnetID, PingCheckConfigPtr> configs_;
133
135 PingCheckConfigPtr global_config_;
136
138 const boost::scoped_ptr<std::mutex> mutex_;
139};
140
142typedef boost::shared_ptr<ConfigCache> ConfigCachePtr;
143
144} // end of namespace ping_check
145} // end of namespace isc
146#endif
This class represents configuration element which is associated with database identifier and the modi...
void setGlobalConfig(PingCheckConfigPtr &config)
Set the global level configuration.
bool findConfig(const dhcp::SubnetID &subnet_id, PingCheckConfigPtr &config)
Get the config for a given subnet.
PingCheckConfigPtr parseAndCacheConfig(const dhcp::SubnetID &subnet_id, data::ConstElementPtr &user_context)
Parses a config string and caches for the given subnet.
virtual ~ConfigCache()=default
Destructor.
void flush()
Discards the subnet entries in the cache.
PingCheckConfigPtr & getGlobalConfig()
Get the global level configuration.
size_t size()
Get the number of entries in the cache.
void cacheConfig(const dhcp::SubnetID &subnet_id, PingCheckConfigPtr &config)
Adds (or replaces) the config for a given subnet to the cache.
boost::posix_time::ptime getLastFlushTime()
Get the last time the cache was flushed.
Houses the Ping check configuration parameters for a single scope (e.g.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
uint32_t SubnetID
Defines unique IPv4 or IPv6 subnet identifier.
Definition subnet_id.h:25
boost::shared_ptr< PingCheckConfig > PingCheckConfigPtr
Defines a shared pointer to a PingCheckConfig.
boost::shared_ptr< ConfigCache > ConfigCachePtr
Defines a shared pointer to a ConfigCache.
Defines the logger used by the top-level component of kea-lfc.