-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean the person lookup cache after deleting
- Loading branch information
1 parent
8f5d110
commit 36a60a2
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,12 @@ use pf::security_event; | |
use pf::constants; | ||
use pf::person qw(person_security_events person_unassign_nodes person_delete person_modify); | ||
use pf::node; | ||
use pf::lookup::person; | ||
use pf::constants qw($default_pid); | ||
use pf::constants::realm; | ||
use pf::error qw(is_error is_success); | ||
use pf::UnifiedApi::Search::Builder::Users; | ||
use pf::lookup::person qw(); | ||
|
||
has 'search_builder_class' => 'pf::UnifiedApi::Search::Builder::Users'; | ||
|
||
|
@@ -658,6 +661,16 @@ sub _can_remove { | |
} | ||
} | ||
|
||
sub post_delete { | ||
my ($self) = @_; | ||
my $item = $self->item; | ||
my $source = $item->{source}; | ||
for my $ctx ('', @pf::constants::realm::CONTEXTS) { | ||
pf::lookup::person::clear_lookup_person($self->id, $item->{source}, $ctx); | ||
} | ||
|
||
} | ||
|
||
=head1 AUTHOR | ||
Inverse inc. <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ use pf::authentication; | |
use pf::pfqueue::producer::redis; | ||
use pf::CHI; | ||
|
||
my $CHI_CACHE = pf::CHI->new( namespace => 'person_lookup' ); | ||
our $CHI_CACHE = pf::CHI->new( namespace => 'person_lookup' ); | ||
|
||
=head2 lookup_person | ||
|
@@ -91,6 +91,14 @@ sub async_lookup_person { | |
$client->submit("general", person_lookup => {pid => $pid, source_id => $source_id, context => $context}); | ||
} | ||
|
||
sub clear_lookup_person { | ||
my ($pid, $source_id, $context) = @_; | ||
my $logger = get_logger(); | ||
my $cache_key = "$source_id.$pid.$context"; | ||
$CHI_CACHE->remove($cache_key); | ||
$logger->info("Clear cache for pid $pid with key $cache_key"); | ||
} | ||
|
||
=head1 AUTHOR | ||
Inverse inc. <[email protected]> | ||
|