MySQL 9.7.0
Source Code Documentation
host_cache_entry.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQLROUTER_HOST_CACHE_ENTRY_H_
27#define MYSQLROUTER_HOST_CACHE_ENTRY_H_
28
29#include <atomic>
30#include <chrono>
31#include <string>
32#include <vector>
33
35
36namespace host_cache {
37
38class Entry {
39 public:
40 using steady_clock = std::chrono::steady_clock;
41 using time_point = steady_clock::time_point;
42
43 std::string hostname_;
44 std::vector<net::ip::address> addresses_;
46 time_point creation_time_{steady_clock::now()};
47 std::atomic<uint64_t> cache_hits_{0};
48 std::atomic<uint64_t> resolve_waiters_peak_{0};
49
50 Entry() {}
51
52 Entry(const Entry &other) { *this = other; }
53
54 Entry &operator=(const Entry &other) {
55 hostname_ = other.hostname_;
56 addresses_ = other.addresses_;
57 ttl_ = other.ttl_;
59 cache_hits_ = other.cache_hits_.load();
61
62 return *this;
63 }
64};
65
66} // namespace host_cache
67
68#endif // MYSQLROUTER_HOST_CACHE_ENTRY_H_
Definition: host_cache_entry.h:38
Entry(const Entry &other)
Definition: host_cache_entry.h:52
std::chrono::seconds ttl_
Definition: host_cache_entry.h:45
std::string hostname_
Definition: host_cache_entry.h:43
std::atomic< uint64_t > cache_hits_
Definition: host_cache_entry.h:47
std::atomic< uint64_t > resolve_waiters_peak_
Definition: host_cache_entry.h:48
time_point creation_time_
Definition: host_cache_entry.h:46
Entry & operator=(const Entry &other)
Definition: host_cache_entry.h:54
std::chrono::steady_clock steady_clock
Definition: host_cache_entry.h:40
steady_clock::time_point time_point
Definition: host_cache_entry.h:41
std::vector< net::ip::address > addresses_
Definition: host_cache_entry.h:44
Entry()
Definition: host_cache_entry.h:50
Definition: host_cache_entry.h:36
std::chrono::seconds seconds
Definition: authorize_manager.cc:70