Cache PPI documents in memory
use PPI::Document
use PPIx::Cache::Memory;
my $cache = PPIx::Cache::Memory->new;
PPI::Document->set_cache( $cache );
This class is similar to PPI::Cache, but it caches to memory instead of disk, which can be useful if you are parsing the same documents from disparate modules that aren't easily able to cooperate, AND you don't have easy access to the filesystem.
my $cache = PPIx::Cache::Memory->new;
Creates a new instance of the memory cache object. This object
can be passed into the PPI::Document class set_cache
method,
and will be used going forward.
my $document = $cache->get_document( $md5sum );
my $document = $cache->get_document( \$source );
Get the document from the cache. You can provide either the MD5 sum, or a reference to a scalar containing the complete source.
$cache->store_document( $document );
Store the given document in the cache.
Since documents are cached until the end of the process, this module is not appropriate for long-lived processes or in memory poor situations.
Graham Ollis [email protected]
This software is copyright (c) 2021-2024 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.