Skip to content

Commit

Permalink
Use ENCODER_FREEZER for the memory backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Dec 17, 2024
1 parent ced7f66 commit 1ce7583
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/pfconfig/backend/memory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use warnings;
use base 'pfconfig::backend';
use CHI;
use pfconfig::empty_string;
use pf::Sereal qw($DECODER $ENCODER_FREEZER);

my $empty_string = pfconfig::empty_string->new;

Expand All @@ -31,7 +32,14 @@ initialize the cache

sub init {
my ($self) = @_;
$self->{cache} = CHI->new(driver => 'Memory', datastore => {},'serializer' => 'Sereal');
$self->{cache} = CHI->new(
driver => 'Memory',
datastore => {},
'serializer' => {
serializer => 'Sereal',
options => { encoder => $ENCODER_FREEZER, decoder => $DECODER }
}
);
}

=head2 set
Expand All @@ -42,7 +50,6 @@ Set value in the CHI cache

sub set {
my ( $self, $key, $value ) = @_;

# There is an issue writing empty strings with CHI Memory driver
# We workaround it using a class that represents an empty string
if ( defined($value) && "$value" eq '' ) {
Expand Down

0 comments on commit 1ce7583

Please sign in to comment.