[Bps-public-commit] r17304 - in Prophet/trunk: t

jesse at bestpractical.com jesse at bestpractical.com
Mon Dec 22 19:27:38 EST 2008


Author: jesse
Date: Mon Dec 22 19:27:38 2008
New Revision: 17304

Modified:
   Prophet/trunk/lib/Prophet/Record.pm
   Prophet/trunk/t/create.t

Log:
 * add limited per-record caching of prop values to cut down on db queries

Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Mon Dec 22 19:27:38 2008
@@ -273,6 +273,7 @@
         $self->uuid( $args{uuid} );
     }
 
+    delete $self->{props};
     return $self->handle->record_exists(
         uuid => $self->uuid,
         type => $self->type
@@ -320,6 +321,7 @@
 
     $self->canonicalize_props( $args{'props'} );
     $self->validate_props( $args{'props'} ) || return undef;
+    delete $self->{props};
     $self->handle->set_record_props(
         type  => $self->type,
         uuid  => $self->uuid,
@@ -339,10 +341,12 @@
 
     confess "get_props called on a record that hasn't been loaded or created yet." if !$self->uuid;
 
-    return $self->handle->get_record_props(
+   return  $self->handle->get_record_props(
         uuid => $self->uuid,
         type => $self->type
-    ) || {};
+    ) || {};;
+    return $self->{props} || {};
+    #$self->{props} ||=
 }
 
 =head2 prop $name
@@ -387,6 +391,7 @@
 
 sub delete {
     my $self = shift;
+    delete $self->{props};
     $self->handle->delete_record( type => $self->type, uuid => $self->uuid );
 
 }

Modified: Prophet/trunk/t/create.t
==============================================================================
--- Prophet/trunk/t/create.t	(original)
+++ Prophet/trunk/t/create.t	Mon Dec 22 19:27:38 2008
@@ -50,6 +50,9 @@
 $cat2->load( uuid => $mei );
 $cat2->set_prop( name => 'age', value => '0.8' );
 
+# Redo our search for cats
+$cats = Prophet::Collection->new( handle => $cxn, type => 'Person' );
+$cats->matching( sub { ( shift->prop('species') || '' ) eq 'cat' } );
 is( $cats->count, 2 );
 for (@$cats) {
     is( $_->prop('age'), "0.8" );



More information about the Bps-public-commit mailing list