Changeset 2505
- Timestamp:
- 06/04/08 07:54:01 (17 months ago)
- Location:
- branches/release-39/lib/MT
- Files:
-
- 5 modified
-
App/Search.pm (modified) (2 diffs)
-
Cache/Null.pm (modified) (1 diff)
-
Cache/Session.pm (modified) (8 diffs)
-
Core.pm (modified) (2 diffs)
-
Memcached.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-39/lib/MT/App/Search.pm
r2463 r2505 173 173 return; 174 174 } 175 $app->{cache_driver} = $cache_driver->new( ttl => $app->config->SearchCacheTTL ); 175 $app->{cache_driver} = $cache_driver->new( 176 ttl => $app->config->SearchCacheTTL, 177 kind => 'CS', 178 ); 176 179 } 177 180 … … 877 880 my ( $cb, $app ) = @_; 878 881 alarm(0) if $app->{__have_throttle}; 882 if ( my $cache_driver = $app->{cache_driver} ) { 883 $cache_driver->purge_stale( 2 * $app->config->SearchCacheTTL ); 884 } 879 885 1; 880 886 } -
branches/release-39/lib/MT/Cache/Null.pm
r2027 r2505 54 54 } 55 55 56 sub purge_stale { 57 my MT::Cache::Null $self = shift; 58 return; 59 } 60 56 61 sub flush_all { 57 62 my MT::Cache::Null $self = shift; -
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 -
branches/release-39/lib/MT/Core.pm
r2377 r2505 774 774 }, 775 775 }, 776 'RemoveExpiredSearchCaches' => { 777 label => 'Remove Expired Search Caches', 778 frequency => 60 * 60 * 24, # once a day 779 code => sub { 780 MT::Core->remove_expired_search_caches; 781 }, 782 }, 776 783 }; 777 784 } … … 803 810 $s->remove if !$s->get('remember'); 804 811 } 812 return ''; 813 } 814 815 sub remove_expired_search_caches { 816 require MT::Session; 817 818 MT::Session->remove( 819 { kind => 'CS', start => [ undef, time - 60 * 60 ] }, 820 { range => { start => 1 } } ); 805 821 return ''; 806 822 } -
branches/release-39/lib/MT/Memcached.pm
r2253 r2505 51 51 $driver_class->disconnect_all; 52 52 } 53 } 54 55 # method for MT::Cache interface 56 sub purge_stale { 57 1; 53 58 } 54 59
