[CDBI] Disable caching of column values?

Perrin Harkins perrin at elem.com
Thu Jun 7 22:51:42 BST 2007


On 6/7/07, Eric Busto <EBusto at nvidia.com> wrote:
> When the still-running application calls an accessor,
> I want it to have the latest data, instead of what is cached inside the
> object.
>
> Can someone tell me how to disable the column value caching, so
> Class::DBI/the object will hit the database every time the accessor is
> called?

Create a new object every time.

my $foo = Foo->retrieve(17);
print $foo->bar;
undef $foo;
my $foo = Foo->retrieve(17); # fetched again
print $foo->bar; # current value

Alternatively, you can delete a single column so it will be fetched again:

$foo->attribute_delete('bar');

That's a private method though and is probably different in different releases.

- Perrin



More information about the ClassDBI mailing list