AmberDB

 view release on metacpan or  search on metacpan

lib/AmberDB/Cache.pm  view on Meta::CPAN

}

# Checks TTL expiration on cache file. Unlinks expired cache and returns 0.
sub _check_cache_ttl {
    my ( $self, $tableid, $file_path ) = @_;
    return 1 unless -e $file_path;

    my $table_info = $self->table_info($tableid);
    my $ttl = $table_info->{cache_ttl} // $self->{cfg}->{cache_ttl};
    if ( defined $ttl && $ttl > 0 ) {
        my $mtime = ( stat($file_path) )[9];
        if ( defined $mtime && ( time() - $mtime ) > $ttl ) {
            $self->table_close($file_path);
            unlink $file_path;
            return 0;
        }
    }
    return 1;
}

# my $cache_file = $dbp->cache_ensure($tableid);



( run in 0.715 second using v1.01-cache-2.11-cpan-4ac696b4eb4 )