Skip to content

Commit f2a24ac

Browse files
committed
refact: filter_timeout by domain name
1 parent 2d07ae3 commit f2a24ac

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/dns_cache/cache_by_record_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl CacheByRecordType{
168168
let clean_cache_data: HashMap<Rtype, CacheByDomainName> = cache_data
169169
.into_iter()
170170
.filter_map(|(rtype, mut host_data)| {
171-
host_data.filter_timeout_host_data();
171+
host_data.filter_timeout_by_domain_name();
172172
if host_data.get_domain_names_data().is_empty() {
173173
None
174174
} else {

src/dns_cache/cache_by_record_type/cache_by_domain_name.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ impl CacheByDomainName {
217217
}
218218

219219
/// For each domain name, it removes the RRStoredData past its TTL.
220-
pub fn filter_timeout_host_data(&mut self) {
221-
let mut new_hash = HashMap::<DomainName, Vec<RRStoredData>>::new();
220+
pub fn filter_timeout_by_domain_name(&mut self) {
221+
let mut new_hash: HashMap<DomainName, Vec<RRStoredData>> = HashMap::<DomainName, Vec<RRStoredData>>::new();
222222
let data = self.get_domain_names_data();
223223
let current_time = Utc::now();
224224
for (domain_name, rr_cache_vec) in data.into_iter() {
@@ -518,7 +518,7 @@ mod host_data_test{
518518
thread::sleep(time::Duration::from_secs(5));
519519
println!("After timeout: {:?}", Utc::now());
520520
//clean the data with expired ttl
521-
cache_by_domain_name.filter_timeout_host_data();
521+
cache_by_domain_name.filter_timeout_by_domain_name();
522522

523523
assert_eq!(cache_by_domain_name.get_domain_names_data().len(), 1);
524524
if let Some(rr_cache_vec) = cache_by_domain_name.get_domain_names_data().get(&domain_name) {
@@ -533,7 +533,7 @@ mod host_data_test{
533533

534534
#[test]
535535
fn timeout_rr_cache_two_domain(){
536-
//this test prove the for iteration in filter_timeout_host_data
536+
//this test prove the for iteration in filter_timeout_by_domain_name
537537
use std::{thread, time};
538538
let mut cache_by_domain_name = CacheByDomainName::new();
539539
let a_rdata = Rdata::A(ARdata::new());
@@ -567,7 +567,7 @@ mod host_data_test{
567567
thread::sleep(time::Duration::from_secs(5));
568568
println!("After timeout: {:?}", Utc::now());
569569
//clean the data with expired ttl
570-
cache_by_domain_name.filter_timeout_host_data();
570+
cache_by_domain_name.filter_timeout_by_domain_name();
571571

572572
println!("The new cache is {:?} ", cache_by_domain_name.get_domain_names_data());
573573

0 commit comments

Comments
 (0)