File::DataClass::Cache - Adds extra methods to the CHI API
0.8.$Revision: 351 $
package File::DataClass::Schema; use File::DataClass::Cache; use Moose; extends qw(File::DataClass); with qw(File::DataClass::Util); has 'cache' => is => 'ro', isa => 'F_DC_Cache', lazy_build => TRUE; has 'cache_attributes' => is => 'ro', isa => 'HashRef', default => sub { return {} }; sub _build_cache { my $self = shift; $self->Cache and return $self->Cache; my $attrs = {}; (my $ns = lc __PACKAGE__) =~ s{ :: }{-}gmx; $attrs->{cache_attributes} = $self->cache_attributes; $attrs->{cache_attributes}->{driver } ||= q(FastMmap); $attrs->{cache_attributes}->{root_dir } ||= NUL.$self->tempdir; $attrs->{cache_attributes}->{namespace} ||= $ns; return $self->Cache( File::DataClass::Cache->new( $attrs ) ); }
Adds meta data and compound keys to the CHI caching API. In instance of this class is created by File::DataClass::Schema
The class defines these attributes
An instance of the CHI cache object
A hash ref passed to the CHI constructor
The class name of the cache object, defaults to CHI
($data, $meta) = $schema->cache->get( $key );
Returns the data and metadata associated with the given key. If no cache entry exists the data returned is undef and the metadata is a hash ref with a key of mtime and a value of 0
undef
mtime
0
($data, $meta, $newest) = $schema->cache->get_by_paths( $paths );
The paths passed in the array ref are concatenated to form a compound key. The CHI cache entry is fetched and the data and meta data returned along with the modification time of the newest file in the list of paths
$mod_time = $schema->cache->get_mtime( $key );
Returns the mod time of a file if it's in the cache. Returns undef if it is not. Returns zero if the filesystem was checked and the file did not exist
$schema->cache->remove( $key );
Removes the CHI cache entry for the given key
($data, $meta) = $schema->cache->set( $key, $data, $meta );
Sets the CHI cache entry for the given key
($data, $meta) = $schema->cache->set_by_paths( $paths, $data, $meta );
Set the CHI cache entry for the compound key formed from the array ref $paths
$paths
$schema->cache->set_mtime( $key, $value );
Sets the mod time in the cache for the given key. Setting the mod time to zero means the filesystem was checked and the file did not exist
($key, $newest) = $schema->cache->_get_key_and_newest( $paths );
Creates a key from the array ref of path names and also returns the most recent mod time. Will return undef for newest if the cache entry is invalid
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Larry Wall - For the Perl programming language
Peter Flanigan, <Support at RoxSoft.co.uk>
<Support at RoxSoft.co.uk>
Copyright (c) 2012 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
To install File::DataClass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::DataClass
CPAN shell
perl -MCPAN -e shell install File::DataClass
For more information on module installation, please visit the detailed CPAN module installation guide.