Resolve typo inifinite too.
Adds a few lines in order to stress that the thawed key of the L1
cache SHOULD ONLY be used for unsafe calls, and not be mixed with
regular (safe) calls.
Test plan:
Nothing to test, but verify the quality of the added comments.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
my $flag = '-CF0'; # 0: scalar, 1: frozen data structure
if (ref($value)) {
my $flag = '-CF0'; # 0: scalar, 1: frozen data structure
if (ref($value)) {
- # Set in L1 cache as a data structure, initially only in frozen form (for performance reasons)
+ # Set in L1 cache as a data structure
+ # We only save the frozen form: we do want to save $value in L1
+ # directly in order to protect it. And thawing now may not be
+ # needed, so improves performance.
$value = $L1_encoder->encode($value);
$L1_cache{$self->{namespace}}{$key}->{frozen} = $value;
$flag = '-CF1';
$value = $L1_encoder->encode($value);
$L1_cache{$self->{namespace}}{$key}->{frozen} = $value;
$flag = '-CF1';
- # We consider an expiry of 0 to be inifinite
+ # We consider an expiry of 0 to be infinite
if ( $expiry ) {
return $set_sub
? $set_sub->( $key, $value, $expiry )
if ( $expiry ) {
return $set_sub
? $set_sub->( $key, $value, $expiry )
if ( exists $L1_cache{$self->{namespace}}{$key} ) {
if (ref($L1_cache{$self->{namespace}}{$key})) {
if ($unsafe) {
if ( exists $L1_cache{$self->{namespace}}{$key} ) {
if (ref($L1_cache{$self->{namespace}}{$key})) {
if ($unsafe) {
+ # ONLY use thawed for unsafe calls !!!
$L1_cache{$self->{namespace}}{$key}->{thawed} ||= $L1_decoder->decode($L1_cache{$self->{namespace}}{$key}->{frozen});
return $L1_cache{$self->{namespace}}{$key}->{thawed};
} else {
$L1_cache{$self->{namespace}}{$key}->{thawed} ||= $L1_decoder->decode($L1_cache{$self->{namespace}}{$key}->{frozen});
return $L1_cache{$self->{namespace}}{$key}->{thawed};
} else {
eval { $thawed = $L1_decoder->decode($L2_value); };
return if $@;
$L1_cache{$self->{namespace}}{$key}->{frozen} = $L2_value;
eval { $thawed = $L1_decoder->decode($L2_value); };
return if $@;
$L1_cache{$self->{namespace}}{$key}->{frozen} = $L2_value;
+ # ONLY save thawed for unsafe calls !!!
$L1_cache{$self->{namespace}}{$key}->{thawed} = $thawed if $unsafe;
return $thawed;
}
$L1_cache{$self->{namespace}}{$key}->{thawed} = $thawed if $unsafe;
return $thawed;
}