Skip to content

uperl/PPIx-Cache-Memory

Repository files navigation

PPIx::Cache::Memory linux windows macos

Cache PPI documents in memory

SYNOPSIS

use PPI::Document
use PPIx::Cache::Memory;

my $cache = PPIx::Cache::Memory->new;
PPI::Document->set_cache( $cache );

DESCRIPTION

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.

CONSTRUCTOR

new

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.

METHODS

get_document

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.

store_document

$cache->store_document( $document );

Store the given document in the cache.

CAVEATS

Since documents are cached until the end of the process, this module is not appropriate for long-lived processes or in memory poor situations.

SEE ALSO

AUTHOR

Graham Ollis [email protected]

COPYRIGHT AND LICENSE

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.

About

Cache PPI documents in memory

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages