Skip to content

Instantly share code, notes, and snippets.

@Whateverable
Created August 14, 2021 02:16
Show Gist options
  • Save Whateverable/bdeaaa12b890556adf2a651d36de3fef to your computer and use it in GitHub Desktop.
Save Whateverable/bdeaaa12b890556adf2a651d36de3fef to your computer and use it in GitHub Desktop.
greppable6
Cache::Async
File Code
ROBERTLE/Cache-Async
…/META6.json :3:
"name" : "Cache::Async",
ROBERTLE/Cache-Async
…/META6.json :13:
"Cache::Async" : "lib/Cache/Async.pm6"
ROBERTLE/Cache-Async
…/README.md :1:
# Cache::Async
ROBERTLE/Cache-Async
…/README.md :28:
my $cache = Cache::Async.new(max-size => 1000, producer => sub ($k) { ... });
ROBERTLE/Cache-Async
…/README.md :33:
Please see the POD in lib/Cache/Async.pm6 for usage scenarios and details on how to use Cache::Async.
ROBERTLE/Cache-Async
…/README.md :37:
Cache::Async is licensed under the Artistic License 2.0.
ROBERTLE/Cache-Async
…/Async.pm6 :1:
unit class Cache::Async;
ROBERTLE/Cache-Async
…/Async.pm6 :5:
=TITLE Cache::Async -- A Concurrent and Asynchronous Cache for Perl 6
ROBERTLE/Cache-Async
…/Async.pm6 :18:
e.g. credentials. Arguments like these can be passed through Cache::Async
ROBERTLE/Cache-Async
…/Async.pm6 :21:
All caches should have a fixed size limit, and so does Cache::Async of course.
ROBERTLE/Cache-Async
…/Async.pm6 :26:
hit rates. Cache::Async supports this through a method that reports hits and
ROBERTLE/Cache-Async
…/Async.pm6 :65:
$cache = Cache::Async.new(producer => sub ($k) { return "[$k]"; },
ROBERTLE/Cache-Async
…/Async.pm6 :180:
The producer function can of course return a promise itself! In this case Cache::Async
ROBERTLE/Cache-Async
…/01-basics.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/01-basics.t :7:
my $cache = Cache::Async.new(producer => sub ($k) { my $i = %producer-count{$k}++; return "$k/$i"; });
ROBERTLE/Cache-Async
…/01-basics.t :24:
dies-ok({ Cache::Async.new(jitter => Duration.new(.2)) }, "c'tor with jitter but no max-age dies");
ROBERTLE/Cache-Async
…/01-basics.t :25:
dies-ok({ Cache::Async.new(jitter => Duration.new(2), max-age => Duration.new(1)) },
ROBERTLE/Cache-Async
…/01-basics.t :27:
dies-ok({ Cache::Async.new(jitter => Duration.new(2), refresh-after => Duration.new(1)) },
ROBERTLE/Cache-Async
…/01-basics.t :29:
dies-ok({ Cache::Async.new(max-age => Duration.new(1), refresh-after => Duration.new(2)) },
ROBERTLE/Cache-Async
…/01-basics.t :31:
lives-ok({ Cache::Async.new(max-age => Duration.new(3), refresh-after => Duration.new(2)),
ROBERTLE/Cache-Async
…/02-async.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/02-async.t :8:
my $cache = Cache::Async.new(producer => sub ($k) { sleep 0.1; $trace-lock.protect({ $trace = $trace ~ $k}); return "[$k]"; });
ROBERTLE/Cache-Async
…/03-expiry.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/03-expiry.t :8:
my $cache = Cache::Async.new(max-size => 4, producer => sub ($k) { $trace-lock.protect({ $trace = $trace ~ $k}); return "[$k]"; });
ROBERTLE/Cache-Async
…/03-expiry.t :48:
$cache = Cache::Async.new(max-age => Duration.new(.8), producer => sub ($k) { $trace-lock.protect({ $trace = $trace ~ $k}); return "[$k]"; });
ROBERTLE/Cache-Async
…/04-exceptions.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/04-exceptions.t :5:
my $cache = Cache::Async.new(producer =>
ROBERTLE/Cache-Async
…/04-exceptions.t :20:
my $cache2 = Cache::Async.new(producer => sub ($k) {
ROBERTLE/Cache-Async
…/05-monitoring.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/05-monitoring.t :5:
my $cache = Cache::Async.new(producer =>
ROBERTLE/Cache-Async
…/06-slurpies.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/06-slurpies.t :5:
my $cache1 = Cache::Async.new(producer => sub ($k, $a) { return "$k: $a"; });
ROBERTLE/Cache-Async
…/06-slurpies.t :6:
my $cache2 = Cache::Async.new(producer => sub ($k, $a, $b) { return "$k: $a $b"; });
ROBERTLE/Cache-Async
…/07-async-producer.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/07-async-producer.t :5:
my $cache = Cache::Async.new(producer => sub ($k) {
ROBERTLE/Cache-Async
…/08-refreshing.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/08-refreshing.t :5:
my $cache = Cache::Async.new(refresh-after => Duration.new(.25), producer => sub ($k) {
ROBERTLE/Cache-Async
…/09-jitter.t :3:
use Cache::Async;
ROBERTLE/Cache-Async
…/09-jitter.t :25:
my $cache = Cache::Async.new(max-age => Duration.new(.25),
ROBERTLE/Cache-Async
…/09-jitter.t :31:
my $jittery-cache = Cache::Async.new(max-age => Duration.new(.5), jitter => Duration.new(.45),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment