Changeset 2505 for branches/release-39/lib/MT/Cache/Session.pm
- Timestamp:
- 06/04/08 07:54:01 (18 months ago)
- Files:
-
- 1 modified
-
branches/release-39/lib/MT/Cache/Session.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-39/lib/MT/Cache/Session.pm
r1596 r2505 14 14 my (%param) = @_; 15 15 $param{'ttl'} ||= 0; 16 $param{'kind'} ||= 'CO'; 16 17 my $self = bless \%param, $class; 17 18 return $self; … … 25 26 if ( $self->{ttl} ) { 26 27 $record = MT::Session::get_unexpired_value( 27 $self->{ttl}, { id => $key, kind => 'CO'} );28 $self->{ttl}, { id => $key, kind => $self->{kind} } ); 28 29 } 29 30 else { 30 $record = MT::Session->load( { id => $key, kind => 'CO'} );31 $record = MT::Session->load( { id => $key, kind => $self->{kind} } ); 31 32 } 32 33 return unless $record; … … 38 39 my @keys = @_; 39 40 40 my @tmp = MT::Session->load( { id => \@keys, kind => 'CO'} )41 my @tmp = MT::Session->load( { id => \@keys, kind => $self->{kind} } ) 41 42 or return; 42 43 … … 61 62 my MT::Cache::Session $self = shift; 62 63 my ($key, $time) = @_; 63 MT::Session->remove( { id => $key, kind => 'CO'} )64 MT::Session->remove( { id => $key, kind => $self->{kind} } ) 64 65 or return 0; 65 66 1; … … 86 87 my $cache = MT::Session->load({ 87 88 id => $key, 88 kind => 'CO',89 kind => $self->{kind}, 89 90 }); 90 91 $cache->remove() if $cache; … … 92 93 $cache->set_values({ 93 94 id => $key, 94 kind => 'CO',95 kind => $self->{kind}, 95 96 start => time, 96 97 data => $val, … … 101 102 sub flush_all { 102 103 my MT::Cache::Session $self = shift; 103 MT::Session->remove({ kind => 'CO' }); 104 MT::Session->remove({ kind => $self->{kind} }); 105 } 106 107 sub purge_stale { 108 my MT::Cache::Session $self = shift; 109 my ( $ttl ) = @_; 110 MT::Session->remove( 111 { kind => $self->{kind}, start => [ undef, time - $ttl ] }, 112 { range => { start => 1 } } 113 ); 114 1; 104 115 } 105 116 … … 150 161 Empty all the caches. 151 162 163 =head2 $cache->purge_stale 164 165 Deletes all the cached objects that are already too old. 166 Takes one argument: $ttl specifies the duration that is considered stale. 167 152 168 =head1 AUTHOR & COPYRIGHT 153 169
