| 1 | ###################################################################### | ||
| 2 | # $Id: SizeAwareSharedMemoryCache.pm,v 1.22 2002/04/07 17:04:46 dclinton Exp $ | ||
| 3 | # Copyright (C) 2001-2003 DeWitt Clinton All Rights Reserved | ||
| 4 | # | ||
| 5 | # Software distributed under the License is distributed on an "AS | ||
| 6 | # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or | ||
| 7 | # implied. See the License for the specific language governing | ||
| 8 | # rights and limitations under the License. | ||
| 9 | ###################################################################### | ||
| 10 | |||
| 11 | |||
| 12 | package Cache::SizeAwareSharedMemoryCache; | ||
| 13 | |||
| 14 | |||
| 15 | use strict; | ||
| 16 | use vars qw( @ISA @EXPORT_OK $NO_MAX_SIZE ); | ||
| 17 | use Cache::Cache qw( $EXPIRES_NEVER ); | ||
| 18 | use Cache::SharedMemoryBackend; | ||
| 19 | use Cache::SizeAwareMemoryCache; | ||
| 20 | use Cache::SharedMemoryCache; | ||
| 21 | use Exporter; | ||
| 22 | |||
| 23 | |||
| 24 | @ISA = qw ( Cache::SizeAwareMemoryCache Exporter ); | ||
| 25 | |||
| 26 | |||
| 27 | @EXPORT_OK = qw( $NO_MAX_SIZE ); | ||
| 28 | |||
| 29 | |||
| 30 | $NO_MAX_SIZE = $Cache::SizeAwareMemoryCache::NO_MAX_SIZE; | ||
| 31 | |||
| 32 | |||
| 33 | sub Clear | ||
| 34 | { | ||
| 35 | return Cache::SharedMemoryCache::Clear( ); | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | sub Purge | ||
| 40 | { | ||
| 41 | return Cache::SharedMemoryCache::Purge( ); | ||
| 42 | } | ||
| 43 | |||
| 44 | |||
| 45 | sub Size | ||
| 46 | { | ||
| 47 | return Cache::SharedMemoryCache::Size( ); | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | sub new | ||
| 52 | { | ||
| 53 | my ( $self ) = _new( @_ ); | ||
| 54 | |||
| 55 | $self->_complete_initialization( ); | ||
| 56 | |||
| 57 | return $self; | ||
| 58 | } | ||
| 59 | |||
| 60 | |||
| 61 | sub _new | ||
| 62 | { | ||
| 63 | my ( $proto, $p_options_hash_ref ) = @_; | ||
| 64 | my $class = ref( $proto ) || $proto; | ||
| 65 | my $self = $class->SUPER::_new( $p_options_hash_ref ); | ||
| 66 | $self->_set_backend( new Cache::SharedMemoryBackend( ) ); | ||
| 67 | return $self; | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | 1; | ||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | __END__ |