|
Lines 259-265
sub set_in_cache {
Link Here
|
| 259 |
|
259 |
|
| 260 |
my $flag = '-CF0'; # 0: scalar, 1: frozen data structure |
260 |
my $flag = '-CF0'; # 0: scalar, 1: frozen data structure |
| 261 |
if (ref($value)) { |
261 |
if (ref($value)) { |
| 262 |
# Set in L1 cache as a data structure, initially only in frozen form (for performance reasons) |
262 |
# Set in L1 cache as a data structure |
|
|
263 |
# We only save the frozen form: we do want to save $value in L1 |
| 264 |
# directly in order to protect it. And thawing now may not be |
| 265 |
# needed, so improves performance. |
| 263 |
$value = $L1_encoder->encode($value); |
266 |
$value = $L1_encoder->encode($value); |
| 264 |
$L1_cache{$key}->{frozen} = $value; |
267 |
$L1_cache{$key}->{frozen} = $value; |
| 265 |
$flag = '-CF1'; |
268 |
$flag = '-CF1'; |
|
Lines 270-276
sub set_in_cache {
Link Here
|
| 270 |
} |
273 |
} |
| 271 |
|
274 |
|
| 272 |
$value .= $flag; |
275 |
$value .= $flag; |
| 273 |
# We consider an expiry of 0 to be inifinite |
276 |
# We consider an expiry of 0 to be infinite |
| 274 |
if ( $expiry ) { |
277 |
if ( $expiry ) { |
| 275 |
return $set_sub |
278 |
return $set_sub |
| 276 |
? $set_sub->( $key, $value, $expiry ) |
279 |
? $set_sub->( $key, $value, $expiry ) |
|
Lines 322-327
sub get_from_cache {
Link Here
|
| 322 |
if ( exists $L1_cache{$key} ) { |
325 |
if ( exists $L1_cache{$key} ) { |
| 323 |
if (ref($L1_cache{$key})) { |
326 |
if (ref($L1_cache{$key})) { |
| 324 |
if ($unsafe) { |
327 |
if ($unsafe) { |
|
|
328 |
# ONLY use thawed for unsafe calls !!! |
| 325 |
$L1_cache{$key}->{thawed} ||= $L1_decoder->decode($L1_cache{$key}->{frozen}); |
329 |
$L1_cache{$key}->{thawed} ||= $L1_decoder->decode($L1_cache{$key}->{frozen}); |
| 326 |
return $L1_cache{$key}->{thawed}; |
330 |
return $L1_cache{$key}->{thawed}; |
| 327 |
} else { |
331 |
} else { |
|
Lines 350-355
sub get_from_cache {
Link Here
|
| 350 |
eval { $thawed = $L1_decoder->decode($L2_value); }; |
354 |
eval { $thawed = $L1_decoder->decode($L2_value); }; |
| 351 |
return if $@; |
355 |
return if $@; |
| 352 |
$L1_cache{$key}->{frozen} = $L2_value; |
356 |
$L1_cache{$key}->{frozen} = $L2_value; |
|
|
357 |
# ONLY save thawed for unsafe calls !!! |
| 353 |
$L1_cache{$key}->{thawed} = $thawed if $unsafe; |
358 |
$L1_cache{$key}->{thawed} = $thawed if $unsafe; |
| 354 |
return $thawed; |
359 |
return $thawed; |
| 355 |
} |
360 |
} |
| 356 |
- |
|
|