DataLoader
view release on metacpan or search on metacpan
t/cache-clear-all.t view on Meta::CPAN
use warnings;
use FindBin ();
use lib "$FindBin::Bin/lib";
use Test::More 0.96;
use Test::Deep;
use DataLoader::Test qw(await);
use AnyEvent;
use Data::Dump qw(dump);
use Mojo::Promise;
use Scalar::Util qw(weaken);
use DataLoader;
subtest 'Complex cache behaviour via clear_all()', sub {
# The loader clears its cache as soon as the batch function is
# dispatched.
my @calls;
my $loader; $loader = DataLoader->new(sub {
$loader->clear_all;
push @calls, \@_;
t/job-queue-ordering.t view on Meta::CPAN
use warnings;
use FindBin ();
use lib "$FindBin::Bin/lib";
use Test::More 0.96;
use Test::Deep;
use DataLoader::Test qw(await id_loader);
use AnyEvent;
use Data::Dump qw(dump);
use Mojo::Promise;
use Scalar::Util qw(weaken);
use DataLoader;
# The JS version manages to do this in one batch call, because next_tick jobs
# come after all Promise job. For Mojo/AnyEvent, next_tick is too fast (happens
# before the promise) but an idle watcher works well.
subtest 'batches loads occuring within promises', sub {
my ($loader, $load_calls) = id_loader();
await(Mojo::Promise->all(
( run in 0.293 second using v1.01-cache-2.11-cpan-65fba6d93b7 )