I'm trying to cache DB records. In my case if a record is not found now doesn't mean it won't be created any time soon. Moreover, it is likely to be created. For this reason it would make sense to skip Nil returned by the producer.
There're two possible ways of handling this situation. More complicated yet more flexible one would be to handle a special control exception. Something like:
class CX::Cache::Async::Bypass is X::Control {
has Mu $.return-value;
}
sub bypass( Mu $return-value ) is export {
CX::Cache::Async::Bypass.new(:$return-value).throw
}
Mu here is to allow returning type objects.
The use by a producer would be:
sub producer( $key ) {
my $ret;
...
if $non-cachable {
bypass $ret
}
$ret
}
I'm trying to cache DB records. In my case if a record is not found now doesn't mean it won't be created any time soon. Moreover, it is likely to be created. For this reason it would make sense to skip
Nilreturned by the producer.There're two possible ways of handling this situation. More complicated yet more flexible one would be to handle a special control exception. Something like:
Muhere is to allow returning type objects.The use by a producer would be: