3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 13:59:47 +01:00

Dequeue cache events when removing SQLite Storage entries

This commit is contained in:
Pragmatic Software 2022-03-23 23:45:00 -07:00
parent 1f3110075a
commit d80b70a2e5
2 changed files with 11 additions and 2 deletions

View File

@ -167,13 +167,16 @@ sub cache_remove {
if (not defined $index2) { if (not defined $index2) {
# remove index1 # remove index1
delete $self->{cache}->{$index1}; delete $self->{cache}->{$index1};
$self->dequeue_decache($index1, '.*');
} else { } else {
# remove index2 # remove index2
delete $self->{cache}->{$index1}->{$index2}; delete $self->{cache}->{$index1}->{$index2};
$self->dequeue_decache($index1, $index2);
# remove index1 if it has no more keys left (aside from _name) # remove index1 if it has no more keys left (aside from _name)
if (not grep { $_ ne '_name' } keys %{$self->{cache}->{$index1}}) { if (not grep { $_ ne '_name' } keys %{$self->{cache}->{$index1}}) {
delete $self->{cache}->{$index1}; delete $self->{cache}->{$index1};
$self->dequeue_decache($index1, '.*');
} }
} }
} }
@ -197,6 +200,12 @@ sub enqueue_decache {
); );
} }
sub dequeue_decache {
my ($self, $index1, $index2) = @_;
my $key = ($index1 eq '.*' ? 'global' : $index1) . ".$index2";
$self->{pbot}->{event_queue}->dequeue("Decache $self->{name} $key");
}
sub create_metadata { sub create_metadata {
my ($self, $columns) = @_; my ($self, $columns) = @_;

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4515, BUILD_REVISION => 4518,
BUILD_DATE => "2022-03-17", BUILD_DATE => "2022-03-23",
}; };
sub initialize {} sub initialize {}