Debian Codegraph @

README

raw ◀ ▶
1 Debian patch touch this file
1 Copyright (C) 2001-2006 DeWitt Clinton All Rights Reserved
2
3 You may distribute under the terms of either the GNU General Public
4 License or the Artistic License, as specified in the Perl README file.
5
6
7 NAME
8
9 Cache::Cache
10
11
12 DESCRIPTION
13
14 The Cache modules are designed to assist a developer in persisting
15 data for a specified period of time. Often these modules are used
16 in web applications to store data locally to save repeated and
17 redundant expensive calls to remote machines or databases. People
18 have also been known to use Cache::Cache for its straightforward
19 interface in sharing data between runs of an application or
20 invocations of a CGI-style script or simply as an easy to use
21 abstraction of the filesystem or shared memory.
22
23 The Cache package provides Cache::Cache, a generic interface
24 for creating persistent data stores. This interface is implemented
25 by the Cache::MemoryCache, Cache::SharedMemoryCache, Cache::FileCache,
26 Cache::SizeAwareFileCache, Cache::SizeAwareMemoryCache, and
27 Cache::SizeAwareSharedMemoryCache classes.
28
29 This work aggregates and extends the obsolete File::Cache and
30 IPC::Cache projects.
31
32
33 CACHE::CACHE VERSUS CHI
34
35 Cache::Cache is in wide use and very stable, but has not changed in years
36 and is no longer actively developed.
37
38 L<CHI|CHI> is the successor to Cache::Cache. It adheres to the basic
39 Cache::Cache API but adds new features and drivers (e.g. FastMmap and
40 Memcached), improves performance, and addresses limitations in the
41 Cache::Cache implementation. The authors recommend the use of CHI going forward.
42
43 Questions about Cache::Cache and CHI may be directed to the perl-cache
44 mailing list at http://groups.google.com/group/perl-cache-discuss.
45
46
47 REQUIREMENTS
48
•49 Digest::SHA
50 Error
51 File::Spec
52 File::Path
53 Storable
54
55
56 OPTIONAL
57
58 IPC::ShareLite
59
60
61 INSTALLATION
62
63 perl Makefile.PL
64 make
65 make test
66 make install
67
68
69 USAGE
70
71 First, choose the best type of cache implementation for your needs.
72 The simplest cache is the MemoryCache, which is suitable for
73 applications that are serving multiple sequential requests, and
74 wish to avoid making redundant expensive queries, such as an
75 Apache/mod_perl application talking to a database. If you wish to
76 share that data between processes, then perhaps the
77 SharedMemoryCache is appropriate, although its behavior is tightly
78 bound to the underlying IPC mechanism, which varies from system to
79 system, and is unsuitable for large objects or large numbers of
80 objects. When the SharedMemoryCache is not acceptable, then
81 FileCache offers all of the same functionality with similar
82 performance metrics, and it is not limited in terms of the number of
83 objects or their size. If you wish to maintain a strict limit on
84 the size of a file system based cache, then the SizeAwareFileCache
85 is the way to go. Similarly, the SizeAwareMemoryCache and the
86 SizeAwareSharedMemoryCache add size management functionality
87 to the MemoryCache and SharedMemoryCache classes respectively.
88
89 Using a cache is simple. Here is some sample code for instantiating
90 and using a file system based cache.
91
92 use Cache::FileCache;
93
94 my $cache = new Cache::FileCache( );
95
96 my $customer = $cache->get( $name );
97
98 if ( not defined $customer )
99 {
100 $customer = get_customer_from_db( $name );
101 $cache->set( $name, $customer, "10 minutes" );
102 }
103
104 return $customer;
105
106 Please refer to the perldoc for Cache::Cache and the related
107 implementations for complete documentation.
108
109 INCOMPATIBLE CHANGES
110
111 Cache::Cache 0.99 contains the following incompatible changes:
112
113 * Error::Simple is thrown on exceptions
114
115 * the get_identifiers method has been deprecated in favor of the
116 get_keys method
117
118 * the internal format of object in a FileCache has been modified,
119 necessitating a clearing of the cache while upgrading (make test
120 does this for the standard cache root)
121
122 Also note that Storable is not forward compatible between all
123 releases. That is, older versions of the Cache will not always
124 be able to read objects written by newer versions. This is
125 unlikely to ever be an issue in production scenarios.
126
127
128 ON LOCKING:
129
130 The FileCache backend uses an temp file and an atomic rename to
131 avoid requiring a lock during the write. This has been demonstrated
132 to be safe across all platforms to date.
133
134 The MemoryCache backend relies on Perl's atomic write to a hash to
135 ensure that a lock is not required.
136
137 The SharedMemoryCache backend uses ShareLite's locking mechanism
138 for safety during the write.
139
140
141 SEE ALSO
142
143 The project homepage at http://perl-cache.googlecode.com/.
144
145 The discussion list at http://groups.google.com/group/perl-cache-discuss.
146
147 The CHI project.
148
149
150 AUTHOR
151
152 Original author: DeWitt Clinton <[email protected]>
153
154 Copyright (C) 2001-2009 DeWitt Clinton
155