Cache::Null - Null implementation of the Cache interface


Cache documentation Contained in the Cache distribution.

Index


Code Index:

NAME

Top

Cache::Null - Null implementation of the Cache interface

SYNOPSIS

Top

  use Cache::Null;

  my $cache = Cache::Null->new();

See Cache for the usage synopsis.

DESCRIPTION

Top

The Cache::Null class implements the Cache interface, but does not actually persist data. This is useful when developing and debugging a system and you wish to easily turn off caching. As a result, all calls return results indicating that there is no data stored.

CONSTRUCTOR

Top

  my $cache = Cache::Null->new( %options )

The constructor takes cache properties as named arguments, for example:

  my $cache = Cache::Null->new( default_expires => '600 sec' );

See 'PROPERTIES' below and in the Cache documentation for a list of all available properties that can be set. However it should be noted that all the existing properties, such as default_expires, have no effect in a Null cache.

METHODS

Top

See 'Cache' for the API documentation.

SEE ALSO

Top

Cache

AUTHOR

Top

 Chris Leishman <chris@leishman.org>
 Based on work by DeWitt Clinton <dewitt@unto.net>

COPYRIGHT

Top


Cache documentation Contained in the Cache distribution.
package Cache::Null;

require 5.006;
use strict;
use warnings;
use Cache::Null::Entry;

use base qw(Cache);
use fields qw(cache_root);

our $VERSION = '2.04';

sub new {
    my Cache::Null $self = shift;
    my $args = $#_? { @_ } : shift;

    $self = fields::new($self) unless ref $self;
    $self->SUPER::new($args);

    return $self;
}

sub entry {
    my Cache::Null $self = shift;
    my ($key) = @_;
    return Cache::Null::Entry->new($self, $key);
}

sub purge {
    #my Cache::Null $self = shift;
}

sub clear {
    #my Cache::Null $self = shift;
}

sub count {
    #my Cache::Null $self = shift;
    return 0;
}

sub size {
    #my Cache::Null $self = shift;
    return 0;
}


# UTILITY METHODS

sub remove_oldest {
    #my Cache::Null $self = shift;
    return undef;
}

sub remove_stalest {
    #my Cache::Null $self = shift;
    return undef;
}



1;
__END__