LocalCache
=title class Zef::Repository::LocalCache
=subtitle A local caching implementation of the Repository interface
Synopsis
use Zef::Fetch;
use Zef::Repository::LocalCache;
# Point cache at default zef cache so there are likely some distributions to see
my $cache = $*HOME.child(".zef/store");
my $repo = Zef::Repository::LocalCache.new(:$cache);
# Print out all available distributions from this repository
say $_.dist.identity for $repo.available;
Description
The Repository
zef uses for its local cache. It is intended to keep track of contents of a directory full
of raku distributions. It provides the optional Repository
method store
which allows it to save/copy
any modules downloaded by other repositories.
Note: distributions installed from local file paths (i.e. zef install ./my-module
) will not be cached
since local development of modules often occurs without immediately bumping versions (and thus a stale
version would soon get cached).
Note: THIS IS PROBABLY NOT ANY MORE EFFICIENT THAN ::Ecosystems BASED REPOSITORIES
At one time json parsing/writing was slow enough that parts of this implementation were faster. Now it is mostly
just useful for dynamically generating the MANIFEST.zef from the directory structure this repository expects
instead of fetching a file like Zef::Repository::Ecosystems
.
Methods
method search
method search(Bool :$strict, *@identities ($, *@), *%fields --> Array[Candidate])
Resolves each identity in @identities
to all of its matching Candidates
. If $strict
is False
then it will
consider partial matches on module short-names (i.e. 'zef search HTTP' will get results for e.g. HTTP::UserAgent
).
method available
method available(*@plugins --> Array[Candidate])
Returns an Array
of all Candidate
provided by this repository instance (i.e. all distributions in the local cache).
method update
method update(--> Nil)
Attempts to update the local file / database using the first of @.mirrors
that successfully fetches.
method store
method store(*@dists --> Nil)
Attempts to store/save/cache each @dist
. Generally this is called when a module is fetched from e.g. cpan so that this
module can cache it locally for next time. Note distributions fetched from local paths (i.e. `zef install .`) do not generally get passed to this method.