line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::DB::Object::Std::Cached; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
870013
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
33
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
484
|
use Rose::DB::Object::Std; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
514
|
use Rose::DB::Object::Cached; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
84
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Rose::DB::Object::Cached Rose::DB::Object::Std); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
*meta_class = \&Rose::DB::Object::Std::meta_class; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
1; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__END__ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Rose::DB::Object::Std::Cached - Memory cached standardized object representation of a single row in a database table. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Category; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use base 'Rose::DB::Object::Std::Cached'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->meta->setup |
28
|
|
|
|
|
|
|
( |
29
|
|
|
|
|
|
|
table => 'categories', |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
columns => |
32
|
|
|
|
|
|
|
[ |
33
|
|
|
|
|
|
|
id => { type => 'int', primary_key => 1 }, |
34
|
|
|
|
|
|
|
name => { type => 'varchar', length => 255 }, |
35
|
|
|
|
|
|
|
description => { type => 'text' }, |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
unique_key => 'name', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
... |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$cat1 = Category->new(id => 123, |
44
|
|
|
|
|
|
|
name => 'Art'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$cat1->save or die $category->error; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$cat2 = Category->new(id => 123); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# This will load from the memory cache, not the database |
52
|
|
|
|
|
|
|
$cat2->load or die $cat2->error; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# $cat2 is the same object as $cat1 |
55
|
|
|
|
|
|
|
print "Yep, cached" if($cat1 eq $cat2); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# No, really, it's the same object |
58
|
|
|
|
|
|
|
$cat1->name('Blah'); |
59
|
|
|
|
|
|
|
print $cat2->name; # prints "Blah" |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
... |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
C<Rose::DB::Object::Std::Cached> is a subclass of both L<Rose::DB::Object::Std> and L<Rose::DB::Object::Cached>. It simply combines the features of both classes. See the L<Rose::DB::Object::Std> and L<Rose::DB::Object::Cached> documentation for more information. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is |
74
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms |
75
|
|
|
|
|
|
|
as Perl itself. |