| Cache::File(3pm) | User Contributed Perl Documentation | Cache::File(3pm) |
Cache::File - Filesystem based implementation of the Cache interface
use Cache::File;
my $cache = Cache::File->new( cache_root => '/tmp/mycache',
default_expires => '600 sec' );
See Cache for the usage synopsis.
The Cache::File class implements the Cache interface. This cache stores data in the filesystem so that it can be shared between processes and persists between process invocations.
my $cache = Cache::File->new( %options )
The constructor takes cache properties as named arguments, for example:
my $cache = Cache::File->new( cache_root => '/tmp/mycache',
lock_level => Cache::File::LOCK_LOCAL(),
default_expires => '600 sec' );
Note that you MUST provide a cache_root property.
See 'PROPERTIES' below and in the Cache documentation for a list of all available properties that can be set.
See 'Cache' for the API documentation.
Cache::File adds the following properties in addition to those discussed in the 'Cache' documentation.
my $ns = $c->cache_root();
my $depth = $c->cache_depth();
my $umask = $c->cache_umask();
my $level = $c->cache_lock_level();
There are a couple of caveats in the current implementation of Cache::File. None of these will present a problem in using the class, it's more of a TODO list of things that could be done better.
There are two points of locking in Cache::File, index locking and entry locking. The index locking is always exclusive and the lock is required briefly during most operations. The entry locking is either shared or exclusive and is also required during most operations. When locking is enabled, File::NFSLock is used to provide the locking for both situations. This is not overly efficient, especially as the entry lock is only ever grabbed whilst the index lock is held.
Cache
Chris Leishman <chris@leishman.org> Based on work by DeWitt Clinton <dewitt@unto.net>
Copyright (C) 2003-2006 Chris Leishman. All Rights Reserved.
This module is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. This program is free software; you can redistribute or modify it under the same terms as Perl itself.
$Id: File.pm,v 1.7 2006/01/31 15:23:58 caleishm Exp $
| 2022-06-09 | perl v5.34.0 |