1PPI::Cache(3) User Contributed Perl Documentation PPI::Cache(3)
2
3
4
6 PPI::Cache - The PPI Document Caching Layer
7
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
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
29 The most common way of using "PPI::Cache" is to provide parameters to
30 the "use" statement at the beginning of your program.
31
32 # Load the class but do not set a cache
33 use PPI::Cache;
34
35 # Use a fairly normal cache location
36 use PPI::Cache path => '/var/cache/ppi-cache';
37
38 Any of the arguments that can be provided to the "new" constructor can
39 also be provided to "use".
40
42 new param => $value, ...
43
44 The "new" constructor creates a new standalone cache object.
45
46 It takes a number of parameters to control the cache.
47
48 path
49 The "path" param sets the base directory for the cache. It must
50 already exist, and must be writable.
51
52 readonly
53 The "readonly" param is a true/false flag that allows the use of an
54 existing cache by a less-privileged user (such as the web user).
55
56 Existing documents will be retrieved from the cache, but new docu‐
57 ments will not be written to it.
58
59 Returns a new "PPI::Cache" object, or dies on error.
60
61 path
62
63 The "path" accessor returns the path on the local filesystem that is
64 the root of the cache.
65
66 readonly
67
68 The "readonly" accessor returns true if documents should not be written
69 to the cache.
70
71 get_document $md5sum ⎪ \$source
72
73 The "get_document" method checks to see if a Document is stored in the
74 cache and retrieves it if so.
75
76 store_document $Document
77
78 The "store_document" method takes a PPI::Document as argument and
79 explicitly adds it to the cache.
80
81 Returns true if saved, or "undef" (or dies) on error.
82
83 FIXME (make this return either one or the other, not both)
84
86 - Finish the basic functionality
87
88 - Add support for use PPI::Cache auto-setting $PPI::Document::CACHE
89
91 See the support section in the main module.
92
94 Adam Kennedy <adamk@cpan.org>
95
97 Copyright (c) 2005 Adam Kennedy. All rights reserved.
98
99 This program is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102 The full text of the license can be found in the LICENSE file included
103 with this module.
104
105
106
107perl v5.8.8 2006-09-23 PPI::Cache(3)