Skip to content

Feature request: provide means of not caching certain values #5

@vrurg

Description

@vrurg

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions