Author: spadkins
Date: Thu Feb 28 15:37:23 2008
New Revision: 10852

Modified:
   p5ee/trunk/App-Repository/lib/App/Repository.pm

Log:
get caching to work with extend_columns

Modified: p5ee/trunk/App-Repository/lib/App/Repository.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository.pm     (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository.pm     Thu Feb 28 15:37:23 2008
@@ -659,7 +659,20 @@
             }
             $hashkey = $sds->hashkey([$table, $params, $cols, $hash_options, 
"row"]);
             if (!$options->{cache_refresh}) {
-                $row = $sds->get_ref($hashkey);
+                my $ref = $sds->get_ref($hashkey);
+                if (defined $ref) {
+                    my ($saved_table, $saved_params, $saved_columns, 
$saved_row, $saved_options) = @$ref;
+                    $row = $saved_row;
+                    if ($options->{extend_columns}) {
+                        @$cols = @$saved_columns;  # so copy the columns
+                    }
+                    else {
+                        $cols = $saved_columns
+                    }
+                }
+                else {
+                    $row = undef;
+                }
             }
         }
 
@@ -694,7 +707,7 @@
             }
 
             if ($sds) {
-                $sds->set_ref($hashkey, $row);
+                $sds->set_ref($hashkey, [$table, $params, $cols, $row, 
$options]);
             }
         }
         if ($sds && $tabledef->{cache_minimum_columns} && $row) {
@@ -939,9 +952,22 @@
                 delete $hash_options->{cache_refresh};
                 $hash_options = undef if (! %$hash_options);
             }
-            $hashkey = $sds->hashkey([$table, $params, $cols, $hash_options, 
"row"]);
+            $hashkey = $sds->hashkey([$table, $params, $cols, $hash_options, 
"rows"]);
             if (!$options->{cache_refresh}) {
-                $rows = $sds->get_ref($hashkey);
+                my $ref = $sds->get_ref($hashkey);
+                if (defined $ref) {
+                    my ($saved_table, $saved_params, $saved_columns, 
$saved_rows, $saved_options) = @$ref;
+                    $rows = $saved_rows;
+                    if ($options->{extend_columns}) {
+                        @$cols = @$saved_columns;  # so copy the columns
+                    }
+                    else {
+                        $cols = $saved_columns
+                    }
+                }
+                else {
+                    $rows = undef;
+                }
             }
         }
 
@@ -982,7 +1008,7 @@
             }
 
             if ($sds) {
-                $sds->set_ref($hashkey, $rows);
+                $sds->set_ref($hashkey, [$table, $params, $cols, $rows, 
$options]);
             }
         }
         if ($sds && $tabledef->{cache_minimum_columns}) {

Reply via email to