Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Cvs P5ee > [svn:p5ee] r111...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 691 of 694
Post > Topic >>

[svn:p5ee] r11124 - p5ee/trunk/App-Repository/bin

by spadkins@[EMAIL PROTECTED] Apr 20, 2008 at 06:13 PM

Author: spadkins
Date: Sun Apr 20 18:13:10 2008
New Revision: 11124

Modified:
   p5ee/trunk/App-Repository/bin/dbget

Log:
updated to support cache control

Modified: p5ee/trunk/App-Repository/bin/dbget
==============================================================================
--- p5ee/trunk/App-Repository/bin/dbget	(original)
+++ p5ee/trunk/App-Repository/bin/dbget	Sun Apr 20 18:13:10 2008
@[EMAIL PROTECTED]
 -15,7 +15,6 @[EMAIL PROTECTED]
             description => "Table name (i.e. --table=customer)",
         },
         params => {
-            required => 1,
             description => "List of params (var=value pairs) (i.e.
--params=\"last_name=Jones|first_name=Mike\")",
         },
         columns => {
@[EMAIL PROTECTED]
 -43,6 +42,9 @[EMAIL PROTECTED]
         cache_refresh => {
             description => "Skip any cached values for the table but save
the results in the cache",
         },
+        hashkey => {
+            description => "hash key to get params from the cache",
+        },
         log_cache => {
             description => "Log cache activity",
         },
@[EMAIL PROTECTED]
 -68,17 +70,40 @[EMAIL PROTECTED]
     my $context  = App->context();
     my $db       = $context->repository($App::options{repository});
     my $table    = $App::options{table};
-    my ($columns);
-    if ($App::options{columns}) {
-        $columns  = [ split(/,/, $App::options{columns}) ];
+    my $verbose  = $App::options{verbose};
+    my ($columns, $params, $headings, $get_options, $cache_rows);
+    if ($table && $App::options{hashkey}) {
+        my $hashkey = $App::options{hashkey};
+        my $table_def = $db->get_table_def($table);
+        my $cache_name = $table_def->{cache_name};
+        if ($cache_name) {
+            my $cache = $context->shared_datastore($cache_name);
+            my $ref = $cache->get_ref($hashkey);
+            if (!$ref) {
+                warn "Nothing in the [$cache_name] cache for table
[$table] with hashkey [$hashkey]\n";
+            }
+            else {
+                ($table, $params, $columns, $cache_rows, $get_options) =
@[EMAIL PROTECTED]
                $get_options->{cache_skip} = 1;
+                print $db->dump([$table, $params, $columns,
$get_options]) if ($verbose);
+            }
+        }
+        else {
+            warn "cache_name option is not set on table $table";
+        }
     }
     else {
-        $columns  = $db->_get_default_columns($table);
+        if ($App::options{columns}) {
+            $columns  = [ split(/,/, $App::options{columns}) ];
+        }
+        else {
+            $columns  = $db->_get_default_columns($table);
+        }
+        die "Must supply the --params option\n" if (! defined
$App::options{params});
+        $params   = { split(/[=>\|]+/, $App::options{params}) };
+        $headings = $App::options{headings} ? [ split(/,/,
$App::options{headings}) ] : [];
+        $get_options = { extend_columns => 1 };
     }
-    my $params   = { split(/[=>\|]+/, $App::options{params}) };
-    my $headings = $App::options{headings} ? [ split(/,/,
$App::options{headings}) ] : [];
-    my $verbose  = $App::options{verbose};
-    my $get_options = { extend_columns => 1 };
     $get_options->{cache_skip} = 1 if ($App::options{cache_skip});
     $get_options->{cache_refresh} = 1 if ($App::options{cache_refresh});
     my $rows     = $db->get_rows($table, $params, $columns,
$get_options);




 1 Posts in Topic:
[svn:p5ee] r11124 - p5ee/trunk/App-Repository/bin
spadkins@[EMAIL PROTECTED  2008-04-20 18:13:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 14:54:58 CDT 2008.