1PPI::Cache(3)         User Contributed Perl Documentation        PPI::Cache(3)
2
3
4

NAME

6       PPI::Cache - The PPI Document Caching Layer
7

SYNOPSIS

9         # Set the cache
10         use PPI::Cache path => '/var/cache/ppi-cache';
11
12         # Manually create a cache
13         my $Cache = PPI::Cache->new(
14             path     => '/var/cache/perl/class-PPI',
15             readonly => 1,
16         );
17

DESCRIPTION

19       "PPI::Cache" provides the default caching functionality for PPI.
20
21       It integrates automatically with PPI itself. Once enabled, any attempt
22       to load a document from the filesystem will be cached via cache.
23
24       Please note that creating a PPI::Document from raw source or something
25       other object will not be cached.
26
27   Using PPI::Cache
28       The most common way of using "PPI::Cache" is to provide parameters to
29       the "use" statement at the beginning of your program.
30
31         # Load the class but do not set a cache
32         use PPI::Cache;
33
34         # Use a fairly normal cache location
35         use PPI::Cache path => '/var/cache/ppi-cache';
36
37       Any of the arguments that can be provided to the "new" constructor can
38       also be provided to "use".
39

METHODS

41   new param => $value, ...
42       The "new" constructor creates a new standalone cache object.
43
44       It takes a number of parameters to control the cache.
45
46       path
47           The "path" param sets the base directory for the cache. It must
48           already exist, and must be writable.
49
50       readonly
51           The "readonly" param is a true/false flag that allows the use of an
52           existing cache by a less-privileged user (such as the web user).
53
54           Existing documents will be retrieved from the cache, but new
55           documents will not be written to it.
56
57       Returns a new "PPI::Cache" object, or dies on error.
58
59   path
60       The "path" accessor returns the path on the local filesystem that is
61       the root of the cache.
62
63   readonly
64       The "readonly" accessor returns true if documents should not be written
65       to the cache.
66
67   get_document $md5sum | \$source
68       The "get_document" method checks to see if a Document is stored in the
69       cache and retrieves it if so.
70
71   store_document $Document
72       The "store_document" method takes a PPI::Document as argument and
73       explicitly adds it to the cache.
74
75       Returns true if saved, or "undef" (or dies) on error.
76
77       FIXME (make this return either one or the other, not both)
78

TO DO

80       - Finish the basic functionality
81
82       - Add support for use PPI::Cache auto-setting $PPI::Document::CACHE
83

SUPPORT

85       See the support section in the main module.
86

AUTHOR

88       Adam Kennedy <adamk@cpan.org>
89
91       Copyright 2005 - 2011 Adam Kennedy.
92
93       This program is free software; you can redistribute it and/or modify it
94       under the same terms as Perl itself.
95
96       The full text of the license can be found in the LICENSE file included
97       with this module.
98
99
100
101perl v5.34.0                      2022-02-02                     PPI::Cache(3)
Impressum