/usr/share/perl5/IPC/PubSub/Cache/DBM_Deep.pm is in libipc-pubsub-perl 0.29-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | package IPC::PubSub::Cache::DBM_Deep;
use strict;
use warnings;
use base 'IPC::PubSub::Cache';
use Storable qw/ nfreeze thaw /;
use DBM::Deep;
use File::Temp qw/ tempfile /;
sub new {
my $class = shift;
my $file = shift;
my $mem = DBM::Deep->new(
file => ((defined $file and length $file) ? $file : $class->default_config),
locking => 1,
autoflush => 1,
);
bless(\$mem, $class);
}
sub default_config {
my (undef, $filename) = tempfile(UNLINK => 1);
return $filename;
}
sub fetch {
my $self = shift;
return map { thaw($$self->get($_)) } @_;
}
sub store {
my ($self, $key, $val, $time, $expiry) = @_;
$$self->put($key => nfreeze([$time, $val]));
}
sub publisher_indices {
my ($self, $chan) = @_;
return { %{ $$self->get("pubs:$chan") || {} } };
}
sub add_publisher {
my ($self, $chan, $pub) = @_;
my $pubs = { %{ $$self->get("pubs:$chan") || {} } };
$pubs->{$pub} = 0;
$$self->put("pubs:$chan", $pubs);
}
sub remove_publisher {
my ($self, $chan, $pub) = @_;
my $pubs = { %{ $$self->get("pubs:$chan") || {} } };
delete $pubs->{$pub};
$$self->put("pubs:$chan", $pubs);
}
sub get_index {
my ($self, $chan, $pub) = @_;
($$self->get("pubs:$chan") || {})->{$pub};
}
sub set_index {
my ($self, $chan, $pub, $idx) = @_;
my $pubs = { %{ $$self->get("pubs:$chan") || {} } };
$pubs->{$pub} = $idx;
$$self->put("pubs:$chan", $pubs);
}
1;
|