fully bypassing persist if persist isn't true
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 15 Mar 2005 17:18:13 +0000 (17:18 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 15 Mar 2005 17:18:13 +0000 (17:18 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@229 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Utils/Cache.pm

index fd212f0..5d2a29b 100644 (file)
@@ -84,7 +84,7 @@ sub put_cache {
        my($self, $key, $value, $expiretime ) = @_;
        return undef unless( $key and $value );
 
-       _load_methods();
+       if($self->{persist}){ _load_methods(); }
 
        $expiretime ||= $max_persist_time;
 
@@ -99,6 +99,8 @@ sub put_cache {
                        ($slot) = $persist_slot_find->run("_CACHEVAL_$key");
                        if(!defined($slot)) {
                                throw OpenSRF::EX::ERROR ("Unable to create cache slot $key in persist server" );
+                       } else {
+                               #XXX destroy the slot and rebuild it to prevent DOS
                        }
                }
 
@@ -115,7 +117,7 @@ sub put_cache {
 sub delete_cache {
        my( $self, $key ) = @_;
        if(!$key) { return undef; }
-       _load_methods();
+       if($self->{persist}){ _load_methods(); }
        $self->{memcache}->delete($key);
        if( $self->{persist} ) {
                $persist_destroy_slot->run("_CACHEVAL_$key");
@@ -129,7 +131,7 @@ sub get_cache {
        my $val = $self->{memcache}->get( $key );
        return $val if defined($val);
 
-       _load_methods();
+       if($self->{persist}){ _load_methods(); }
 
        # if not in memcache but we are persisting, the put it into memcache
        if( $self->{"persist"} ) {