/usr/share/perl5/Cache/MemoryBackend.pm is in libcache-cache-perl 1.06-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | ######################################################################
# $Id: MemoryBackend.pm,v 1.10 2003/01/16 18:10:16 dclinton Exp $
# Copyright (C) 2001-2003 DeWitt Clinton All Rights Reserved
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or
# implied. See the License for the specific language governing
# rights and limitations under the License.
######################################################################
package Cache::MemoryBackend;
use strict;
use Cache::CacheUtils qw( Clone_Data );
my $Store_Ref = { };
sub new
{
my ( $proto ) = @_;
my $class = ref( $proto ) || $proto;
my $self = {};
$self = bless( $self, $class );
$self->_initialize_memory_backend( );
return $self;
}
sub delete_key
{
my ( $self, $p_namespace, $p_key ) = @_;
delete $self->_get_store_ref( )->{ $p_namespace }{ $p_key };
}
sub delete_namespace
{
my ( $self, $p_namespace ) = @_;
delete $self->_get_store_ref( )->{ $p_namespace };
}
sub get_keys
{
my ( $self, $p_namespace ) = @_;
return keys %{ $self->_get_store_ref( )->{ $p_namespace } };
}
sub get_namespaces
{
my ( $self ) = @_;
return keys %{ $self->_get_store_ref( ) };
}
sub get_size
{
my ( $self, $p_namespace, $p_key ) = @_;
if ( exists $self->_get_store_ref( )->{ $p_namespace }{ $p_key } )
{
return length $self->_get_store_ref( )->{ $p_namespace }{ $p_key };
}
else
{
return 0;
}
}
sub restore
{
my ( $self, $p_namespace, $p_key ) = @_;
return Clone_Data( $self->_get_store_ref( )->{ $p_namespace }{ $p_key } );
}
sub store
{
my ( $self, $p_namespace, $p_key, $p_data ) = @_;
$self->_get_store_ref( )->{ $p_namespace }{ $p_key } = $p_data;
}
sub _initialize_memory_backend
{
my ( $self ) = @_;
if ( not defined $self->_get_store_ref( ) )
{
$self->_set_store_ref( { } );
}
}
sub _get_store_ref
{
return $Store_Ref;
}
sub _set_store_ref
{
my ( $self, $p_store_ref ) = @_;
$Store_Ref = $p_store_ref;
}
1;
__END__
=pod
=head1 NAME
Cache::MemoryBackend -- a memory based persistance mechanism
=head1 DESCRIPTION
The MemoryBackend class is used to persist data to memory
=head1 SYNOPSIS
my $backend = new Cache::MemoryBackend( );
See Cache::Backend for the usage synopsis.
=head1 METHODS
See Cache::Backend for the API documentation.
=head1 SEE ALSO
Cache::Backend, Cache::FileBackend, Cache::ShareMemoryBackend
=head1 AUTHOR
Original author: DeWitt Clinton <dewitt@unto.net>
Last author: $Author: dclinton $
Copyright (C) 2001-2003 DeWitt Clinton
=cut
|