Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 045e18d

Browse files
committedJun 4, 2025·
Clear MethodsV2 cache on engine reset
A previous commit introduced memoization of one particular function in MethodsV2. Make sure we can invalidate the cache, and make sure it happens when calling Zonemaster::Engine::reset().
1 parent ca192b7 commit 045e18d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
 

‎lib/Zonemaster/Engine.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ sub reset {
231231
Zonemaster::Engine::Nameserver->empty_cache();
232232
$logger->clear_history() if $logger;
233233
Zonemaster::Engine::Recursor->clear_cache();
234+
Zonemaster::Engine::TestMethodsV2->clear_cache();
234235
return;
235236
}
236237

@@ -408,7 +409,8 @@ Set the logger's start time to the current time.
408409
=item reset()
409410
410411
Reset logger start time to current time, empty the list of log messages, clear
411-
nameserver object cache and recursor cache.
412+
nameserver object cache, clear recursor cache and clear all cached results of
413+
MethodsV2.
412414
413415
=back
414416

‎lib/Zonemaster/Engine/TestMethodsV2.pm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Takes a L<Zonemaster::Engine::Zone> object.
3636
3737
Returns an arrayref of L<Zonemaster::Engine::Nameserver> objects, or C<undef> if no parent zone was found.
3838
39+
The result of this Method is cached for performance reasons. This cache can be invalidated by calling C<clear_cache()> if necessary.
40+
3941
=back
4042
4143
=cut
@@ -786,4 +788,19 @@ sub get_zone_ns_ips {
786788
return [ uniq sort @ns_ips ];
787789
}
788790

791+
792+
=over
793+
794+
=item clear_cache()
795+
796+
Clears previously cached results of the C<get_parent_ns_ips()> method.
797+
798+
=back
799+
800+
=cut
801+
802+
sub clear_cache() {
803+
Memoize::flush_cache(\&get_parent_ns_ips);
804+
}
805+
789806
1;

0 commit comments

Comments
 (0)
Please sign in to comment.