File | /data/SimpleDB-Class/author.t/../lib/SimpleDB/Class.pm |
Statements Executed | 268 |
Statement Execution Time | 2.04ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.56ms | 211ms | BEGIN@141 | SimpleDB::Class::
1 | 1 | 1 | 1.44ms | 43.0ms | BEGIN@139 | SimpleDB::Class::
1 | 1 | 1 | 962µs | 42.3ms | BEGIN@140 | SimpleDB::Class::
1 | 1 | 1 | 815µs | 11.8ms | BEGIN@142 | SimpleDB::Class::
61 | 6 | 4 | 494µs | 685µs | add_domain_prefix | SimpleDB::Class::
1 | 1 | 1 | 347µs | 228ms | BEGIN@138 | SimpleDB::Class::
7 | 5 | 2 | 133µs | 745µs | domain | SimpleDB::Class::
2 | 2 | 1 | 53µs | 145ms | list_domains | SimpleDB::Class::
1 | 1 | 1 | 37µs | 2.02ms | BEGIN@137 | SimpleDB::Class::
1 | 1 | 1 | 35µs | 8.42ms | __ANON__[../lib/SimpleDB/Class.pm:328] | SimpleDB::Class::
1 | 1 | 1 | 16µs | 40µs | __ANON__[../lib/SimpleDB/Class.pm:219] | SimpleDB::Class::
1 | 1 | 1 | 14µs | 134µs | BEGIN@450 | SimpleDB::Class::
1 | 1 | 1 | 14µs | 56.9ms | load_namespaces | SimpleDB::Class::
1 | 1 | 1 | 4µs | 4µs | __ANON__[../lib/SimpleDB/Class.pm:341] | SimpleDB::Class::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package SimpleDB::Class; | ||||
2 | |||||
3 | =head1 NAME | ||||
4 | |||||
5 | SimpleDB::Class - An Object Relational Mapper (ORM) for the Amazon SimpleDB service. | ||||
6 | |||||
7 | =head1 SYNOPSIS | ||||
8 | |||||
9 | package Library; | ||||
10 | |||||
11 | use Moose; | ||||
12 | extends 'SimpleDB::Class'; | ||||
13 | |||||
14 | __PACKAGE__->load_namespaces(); | ||||
15 | |||||
16 | 1; | ||||
17 | |||||
18 | package Library::Book; | ||||
19 | |||||
20 | use Moose; | ||||
21 | extends 'SimpleDB::Class::Item'; | ||||
22 | |||||
23 | __PACKAGE__->set_domain_name('book'); | ||||
24 | __PACKAGE__->add_attributes( | ||||
25 | title => { isa => 'Str', default => 'Untitled' }, | ||||
26 | publish_date => { isa => 'Date' }, | ||||
27 | edition => { isa => 'Int', default => 1 }, | ||||
28 | isbn => { isa => 'Str' }, | ||||
29 | publisherId => { isa => 'Str' }, | ||||
30 | author => { isa => 'Str' }, | ||||
31 | ); | ||||
32 | __PACKAGE__->belongs_to('publisher', 'Library::Publisher', 'publisherId'); | ||||
33 | |||||
34 | 1; | ||||
35 | |||||
36 | package Library::Publisher; | ||||
37 | |||||
38 | use Moose; | ||||
39 | extends 'SimpleDB::Class::Item'; | ||||
40 | |||||
41 | __PACKAGE__->set_domain_name('publisher'); | ||||
42 | __PACKAGE__->add_attributes({ | ||||
43 | name => { isa => 'Str' }, | ||||
44 | }); | ||||
45 | __PACKAGE__->has_many('books', 'Library::Book', 'publisherId'); | ||||
46 | |||||
47 | 1; | ||||
48 | |||||
49 | use 5.010; | ||||
50 | use Library; | ||||
51 | use DateTime; | ||||
52 | |||||
53 | my $library = Library->new(access_key => 'xxx', secret_key => 'yyy', cache_servers=>\@servers ); | ||||
54 | |||||
55 | my $specific_book = $library->domain('book')->find('id goes here'); | ||||
56 | |||||
57 | my $books = $library->domain('publisher')->find($id)->books; | ||||
58 | my $books = $library->domain('book')->search( where => {publish_date => ['between', DateTime->new(year=>2001), DateTime->new(year=>2003)]} ); | ||||
59 | while (my $book = $books->next) { | ||||
60 | say $book->title; | ||||
61 | } | ||||
62 | |||||
63 | =head1 DESCRIPTION | ||||
64 | |||||
65 | SimpleDB::Class gives you a way to persist your objects in Amazon's SimpleDB service search them easily. It hides the mess of web services, pseudo SQL, and XML document formats that you'd normally need to deal with to use the service, and gives you a tight clean Perl API to access it. | ||||
66 | |||||
67 | On top of being a simple to use ORM that functions in a manner similar to L<DBIx::Class>, SimpleDB::Class has some other niceties that make dealing with SimpleDB easier: | ||||
68 | |||||
69 | =over | ||||
70 | |||||
71 | =item * | ||||
72 | |||||
73 | It uses memcached to cache objects locally so that most of the time you don't have to care that SimpleDB is eventually consistent. This also speeds up many requests. See Eventual Consistency below for details. | ||||
74 | |||||
75 | =item * | ||||
76 | |||||
77 | It automatically formats dates and integers for sortability in SimpleDB. | ||||
78 | |||||
79 | =item * | ||||
80 | |||||
81 | It automatically casts date fields as L<DateTime> objects. | ||||
82 | |||||
83 | =item * | ||||
84 | |||||
85 | It automatically serializes hashes into JSON so they can be stored in SimpleDB domain attributes, and deserializes on retrieval. | ||||
86 | |||||
87 | =item * | ||||
88 | |||||
89 | It gives you an easy way to handle pagination of data. See L<SimpleDB::Class::ResultSet/"paginate">. | ||||
90 | |||||
91 | =item * | ||||
92 | |||||
93 | It uses L<Moose> for everything, which makes it easy to use Moose's introspection features or method insertion features. | ||||
94 | |||||
95 | =item * | ||||
96 | |||||
97 | It automatically generates UUID based ItemNames (unique IDs) if you don't want to supply an ID yourself. | ||||
98 | |||||
99 | =item * | ||||
100 | |||||
101 | It has built in domain prefixing to account for the fact that you can't create multiple SimpleDB instances under the same account. | ||||
102 | |||||
103 | =item * | ||||
104 | |||||
105 | It ignores attributes in your items that aren't in your L<SimpleDB::Class::Item> subclasses. | ||||
106 | |||||
107 | =item * | ||||
108 | |||||
109 | L<SimpleDB::Class::ResultSet>s automatically fetch additional items from SimpleDB if a next token is provided, so you don't have to care that SimpleDB sends you back data in small packets. | ||||
110 | |||||
111 | =item * | ||||
112 | |||||
113 | It allows for multiple similar object types to be stored in a single domain and then cast into different classes at retrieval time. See L<SimpleDB::Class::Item/"recast_using"> for details. | ||||
114 | |||||
115 | =item * | ||||
116 | |||||
117 | It allows for mass updates and deletes on L<SimpleDB::Class::ResultSet>s, which is a nice level of automation to keep your code small. | ||||
118 | |||||
119 | =back | ||||
120 | |||||
121 | =head2 Eventual Consistency | ||||
122 | |||||
123 | SimpleDB is eventually consistent, which means that if you do a write, and then read directly after the write you may not get what you just wrote. L<SimpleDB::Class> gets around this problem for the post part because it caches all L<SimpleDB::Class::Item>s in memcached. That is to say that if an object can be read from cache, it will be. The one area where this falls short are some methods in L<SimpleDB::Class::Domain> and L<SimpleDB::Class::ResultSet> that perform searches on the database which look up items based upon their attributes rather than based upon id. Even in those cases, once an object is located we try to pull it from cache rather than using the data SimpleDB gave us, simply because the cache may be more current. However, a search result may return too few (inserts pending) or too many (deletes pending) results in L<SimpleDB::Class::ResultSet>, or it may return an object which no longer fits certain criteria that you just searched for (updates pending). As long as you're aware of it, and write your programs accordingly, there shouldn't be a problem. | ||||
124 | |||||
125 | At the end of February 2010 Amazon added a C<ConsistentRead> option to SimpleDB, which means you don't have to care about eventual consistency if you wish to sacrifice some performance. We have exposed this as an option for you to turn on in the methods like C<search> in L<SimpleDB::Class::Domain> where you have to be concerned about eventual consistency. | ||||
126 | |||||
127 | Does all this mean that this module makes SimpleDB as ACID compliant as a traditional RDBMS? No it does not. There are still no locks on domains (think tables), or items (think rows). So you probably shouldn't be storing sensitive financial transactions in this. We just provide an easy to use API that will allow you to more easily and a little more safely take advantage of Amazon's excellent SimpleDB service for things like storing logs, metadata, and game data. | ||||
128 | |||||
129 | For more information about eventual consistency visit L<http://en.wikipedia.org/wiki/Eventual_consistency> or the eventual consistency section of the Amazon SimpleDB Developer's Guide at L<http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/EventualConsistencySummary.html>. | ||||
130 | |||||
131 | =head1 METHODS | ||||
132 | |||||
133 | The following methods are available from this class. | ||||
134 | |||||
135 | =cut | ||||
136 | |||||
137 | 3 | 28µs | 2 | 4.00ms | # spent 2.02ms (37µs+1.98) within SimpleDB::Class::BEGIN@137 which was called
# once (37µs+1.98ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 137 # spent 2.02ms making 1 call to SimpleDB::Class::BEGIN@137
# spent 1.98ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
138 | 3 | 146µs | 2 | 253ms | # spent 228ms (347µs+228) within SimpleDB::Class::BEGIN@138 which was called
# once (347µs+228ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 138 # spent 228ms making 1 call to SimpleDB::Class::BEGIN@138
# spent 24.7ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389] |
139 | 3 | 207µs | 1 | 43.0ms | # spent 43.0ms (1.44+41.6) within SimpleDB::Class::BEGIN@139 which was called
# once (1.44ms+41.6ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 139 # spent 43.0ms making 1 call to SimpleDB::Class::BEGIN@139 |
140 | 3 | 197µs | 1 | 42.3ms | # spent 42.3ms (962µs+41.4) within SimpleDB::Class::BEGIN@140 which was called
# once (962µs+41.4ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 140 # spent 42.3ms making 1 call to SimpleDB::Class::BEGIN@140 |
141 | 3 | 143µs | 1 | 211ms | # spent 211ms (1.56+209) within SimpleDB::Class::BEGIN@141 which was called
# once (1.56ms+209ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 141 # spent 211ms making 1 call to SimpleDB::Class::BEGIN@141 |
142 | 3 | 525µs | 2 | 11.9ms | # spent 11.8ms (815µs+11.0) within SimpleDB::Class::BEGIN@142 which was called
# once (815µs+11.0ms) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 142 # spent 11.8ms making 1 call to SimpleDB::Class::BEGIN@142
# spent 48µs making 1 call to Exporter::import |
143 | |||||
144 | #-------------------------------------------------------- | ||||
145 | |||||
146 | =head2 new ( params ) | ||||
147 | |||||
148 | =head3 params | ||||
149 | |||||
150 | A hash containing the parameters to pass in to this method. | ||||
151 | |||||
152 | =head4 access_key | ||||
153 | |||||
154 | The access key given to you from Amazon when you sign up for the SimpleDB service at this URL: L<http://aws.amazon.com/simpledb/> | ||||
155 | |||||
156 | =head4 secret_key | ||||
157 | |||||
158 | The secret access key given to you from Amazon. | ||||
159 | |||||
160 | =head4 cache_servers | ||||
161 | |||||
162 | An array reference of cache servers. See L<SimpleDB::Class::Cache> for details. | ||||
163 | |||||
164 | =head4 simpledb_uri | ||||
165 | |||||
166 | An optional L<URI> object to connect to an alternate SimpleDB server. See also L<SimpleDB::Client/"simpledb_uri">. | ||||
167 | |||||
168 | =head4 domain_prefix | ||||
169 | |||||
170 | An optional string that is prepended to all domain names wherever they are used in the system. | ||||
171 | |||||
172 | =cut | ||||
173 | |||||
174 | #-------------------------------------------------------- | ||||
175 | |||||
176 | =head2 load_namespaces ( [ namespace ] ) | ||||
177 | |||||
178 | Class method. Loads all the modules in the current namespace, so if you subclass SimpleDB::Class with a package called Library (as in the example provided), then everything in the Library namespace would be loaded automatically. Should be called to load all the modules you subclass, so you don't have to manually use each of them. | ||||
179 | |||||
180 | =head3 namespace | ||||
181 | |||||
182 | Specify a specific namespace like Library::SimpleDB if you don't want everything in the Library namespace to be loaded. | ||||
183 | |||||
184 | =cut | ||||
185 | |||||
186 | # spent 56.9ms (14µs+56.9) within SimpleDB::Class::load_namespaces which was called
# once (14µs+56.9ms) by main::BEGIN@13 at line 6 of lib/Foo.pm | ||||
187 | 1 | 2µs | my ($class, $namespace) = @_; | ||
188 | 1 | 1µs | $namespace ||= $class; # if no namespace is set | ||
189 | 1 | 9µs | 1 | 56.9ms | useall $namespace; # spent 56.9ms making 1 call to Module::Find::useall |
190 | } | ||||
191 | |||||
192 | #-------------------------------------------------------- | ||||
193 | |||||
194 | =head2 cache_servers ( ) | ||||
195 | |||||
196 | Returns the cache server array reference passed into the constructor. | ||||
197 | |||||
198 | =cut | ||||
199 | |||||
200 | 1 | 3µs | 1 | 1.52ms | has cache_servers => ( # spent 1.52ms making 1 call to Moose::has |
201 | is => 'ro', | ||||
202 | required => 1, | ||||
203 | ); | ||||
204 | |||||
205 | #-------------------------------------------------------- | ||||
206 | |||||
207 | =head2 cache ( ) | ||||
208 | |||||
209 | Returns a reference to the L<SimpleDB::Class::Cache> instance. | ||||
210 | |||||
211 | =cut | ||||
212 | |||||
213 | has cache => ( | ||||
214 | is => 'ro', | ||||
215 | lazy => 1, | ||||
216 | # spent 40µs (16+23) within SimpleDB::Class::__ANON__[../lib/SimpleDB/Class.pm:219] which was called
# once (16µs+23µs) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm | ||||
217 | 1 | 900ns | my $self = shift; | ||
218 | 1 | 14µs | 2 | 24µs | return SimpleDB::Class::Cache->new(servers=>$self->cache_servers); # spent 21µs making 1 call to SimpleDB::Class::Cache::new
# spent 3µs making 1 call to SimpleDB::Class::cache_servers |
219 | }, | ||||
220 | 1 | 4µs | 1 | 1.35ms | ); # spent 1.35ms making 1 call to Moose::has |
221 | |||||
222 | #-------------------------------------------------------- | ||||
223 | |||||
224 | =head2 access_key ( ) | ||||
225 | |||||
226 | Returns the access key passed to the constructor. | ||||
227 | |||||
228 | =cut | ||||
229 | |||||
230 | 1 | 2µs | 1 | 945µs | has 'access_key' => ( # spent 945µs making 1 call to Moose::has |
231 | is => 'ro', | ||||
232 | required => 1, | ||||
233 | documentation => 'The AWS SimpleDB access key id provided by Amazon.', | ||||
234 | ); | ||||
235 | |||||
236 | #-------------------------------------------------------- | ||||
237 | |||||
238 | =head2 secret_key ( ) | ||||
239 | |||||
240 | Returns the secret key passed to the constructor. | ||||
241 | |||||
242 | =cut | ||||
243 | |||||
244 | 1 | 1µs | 1 | 956µs | has 'secret_key' => ( # spent 956µs making 1 call to Moose::has |
245 | is => 'ro', | ||||
246 | required => 1, | ||||
247 | documentation => 'The AWS SimpleDB secret access key id provided by Amazon.', | ||||
248 | ); | ||||
249 | |||||
250 | #-------------------------------------------------------- | ||||
251 | |||||
252 | =head2 simpledb_uri ( ) | ||||
253 | |||||
254 | Returns the L<URI> object passed into the constructor, if any. See also L<SimpleDB::Client/"simpledb_uri">. | ||||
255 | |||||
256 | =head2 has_simpledb_uri ( ) | ||||
257 | |||||
258 | Returns a boolean indicating whether the user has overridden the URI. | ||||
259 | |||||
260 | =cut | ||||
261 | |||||
262 | 1 | 3µs | 1 | 1.23ms | has simpledb_uri => ( # spent 1.23ms making 1 call to Moose::has |
263 | is => 'ro', | ||||
264 | predicate => 'has_simpledb_uri', | ||||
265 | default => undef, | ||||
266 | ); | ||||
267 | |||||
268 | |||||
269 | #-------------------------------------------------------- | ||||
270 | |||||
271 | =head2 domain_prefix ( ) | ||||
272 | |||||
273 | Returns the value passed into the constructor. | ||||
274 | |||||
275 | =head2 has_domain_prefix ( ) | ||||
276 | |||||
277 | Returns a boolean indicating whether the user has specified a domain_prefix. | ||||
278 | |||||
279 | =cut | ||||
280 | |||||
281 | 1 | 2µs | 1 | 1.24ms | has domain_prefix => ( # spent 1.24ms making 1 call to Moose::has |
282 | is => 'ro', | ||||
283 | predicate => 'has_domain_prefix', | ||||
284 | default => undef, | ||||
285 | ); | ||||
286 | |||||
287 | #-------------------------------------------------------- | ||||
288 | |||||
289 | =head2 add_domain_prefix ( domain ) | ||||
290 | |||||
291 | If the domain_prefix is set, this method will apply it do a passed in domain name. If it's not, it will simply return the domain anme as is. | ||||
292 | |||||
293 | B<NOTE:> This is used mostly internally to SimpleDB::Class, so unless you're extending SimpleDB::Class itself, rather than just using it, you don't have to use this method. | ||||
294 | |||||
295 | =head3 domain | ||||
296 | |||||
297 | The domain to apply the prefix to. | ||||
298 | |||||
299 | =cut | ||||
300 | |||||
301 | # spent 685µs (494+192) within SimpleDB::Class::add_domain_prefix which was called 61 times, avg 11µs/call:
# 19 times (146µs+59µs) by SimpleDB::Class::SQL::to_sql at line 393 of ../lib/SimpleDB/Class/SQL.pm, avg 11µs/call
# 18 times (150µs+59µs) by SimpleDB::Class::ResultSet::next at line 460 of ../lib/SimpleDB/Class/ResultSet.pm, avg 12µs/call
# 12 times (95µs+36µs) by SimpleDB::Class::Item::put at line 477 of ../lib/SimpleDB/Class/Item.pm, avg 11µs/call
# 6 times (50µs+20µs) by SimpleDB::Class::Domain::find at line 152 of ../lib/SimpleDB/Class/Domain.pm, avg 12µs/call
# 3 times (27µs+11µs) by SimpleDB::Class::Domain::delete at line 118 of ../lib/SimpleDB/Class/Domain.pm, avg 13µs/call
# 3 times (26µs+8µs) by SimpleDB::Class::Domain::create at line 102 of ../lib/SimpleDB/Class/Domain.pm, avg 11µs/call | ||||
302 | 61 | 69µs | my ($self, $domain) = @_; | ||
303 | 61 | 186µs | 61 | 192µs | if ($self->has_domain_prefix) { # spent 192µs making 61 calls to SimpleDB::Class::has_domain_prefix, avg 3µs/call |
304 | return $self->domain_prefix . $domain; | ||||
305 | } | ||||
306 | 61 | 163µs | return $domain; | ||
307 | } | ||||
308 | |||||
309 | |||||
310 | #-------------------------------------------------------- | ||||
311 | |||||
312 | =head2 http ( ) | ||||
313 | |||||
314 | Returns the L<SimpleDB::Client> instance used to connect to the SimpleDB service. | ||||
315 | |||||
316 | =cut | ||||
317 | |||||
318 | has http => ( | ||||
319 | is => 'ro', | ||||
320 | lazy => 1, | ||||
321 | # spent 8.42ms (35µs+8.39) within SimpleDB::Class::__ANON__[../lib/SimpleDB/Class.pm:328] which was called
# once (35µs+8.39ms) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm | ||||
322 | 1 | 800ns | my $self = shift; | ||
323 | 1 | 17µs | 2 | 14µs | my %params = (access_key=>$self->access_key, secret_key=>$self->secret_key); # spent 10µs making 1 call to SimpleDB::Class::access_key
# spent 3µs making 1 call to SimpleDB::Class::secret_key |
324 | 1 | 4µs | 1 | 3µs | if ($self->has_simpledb_uri) { # spent 3µs making 1 call to SimpleDB::Class::has_simpledb_uri |
325 | $params{simpledb_uri} = $self->simpledb_uri; | ||||
326 | } | ||||
327 | 1 | 12µs | 1 | 8.37ms | return SimpleDB::Client->new(%params); # spent 8.37ms making 1 call to SimpleDB::Client::new |
328 | }, | ||||
329 | 1 | 4µs | 1 | 976µs | ); # spent 976µs making 1 call to Moose::has |
330 | |||||
331 | #-------------------------------------------------------- | ||||
332 | |||||
333 | =head2 domain_names ( ) | ||||
334 | |||||
335 | Class method. Returns a hashref of the domain names and class names registered from subclassing L<SimpleDB::Class::Domain> and calling set_name. | ||||
336 | |||||
337 | =cut | ||||
338 | |||||
339 | 1 | 5µs | class_has 'domain_names' => ( | ||
340 | is => 'rw', | ||||
341 | # spent 4µs within SimpleDB::Class::__ANON__[../lib/SimpleDB/Class.pm:341] which was called
# once (4µs+0s) by Class::MOP::Class:::around at line 78 of MooseX/ClassAttribute/Role/Meta/Attribute.pm | ||||
342 | 1 | 6µs | 1 | 11.3ms | ); # spent 11.3ms making 1 call to MooseX::ClassAttribute::class_has |
343 | |||||
344 | #-------------------------------------------------------- | ||||
345 | |||||
346 | =head2 domain ( moniker ) | ||||
347 | |||||
348 | Returns an instanciated L<SimpleDB::Class::Domain> based upon its L<SimpleDB::Class::Item> classname or its domain name. | ||||
349 | |||||
350 | =head3 moniker | ||||
351 | |||||
352 | Can either be the L<SimpleDB::Class::Item> subclass name, or the domain name. | ||||
353 | |||||
354 | =cut | ||||
355 | |||||
356 | # spent 745µs (133+611) within SimpleDB::Class::domain which was called 7 times, avg 106µs/call:
# 3 times (41µs+205µs) by Foo::Domain::children or Foo::Parent::domains at line 207 of ../lib/SimpleDB/Class/Item.pm, avg 82µs/call
# once (37µs+137µs) by main::RUNTIME at line 20 of 05.Domain_and_Item.t
# once (21µs+111µs) by main::RUNTIME at line 76 of 05.Domain_and_Item.t
# once (18µs+80µs) by main::RUNTIME at line 24 of 05.Domain_and_Item.t
# once (16µs+78µs) by SimpleDB::Class::Item::__ANON__[../lib/SimpleDB/Class/Item.pm:280] at line 279 of ../lib/SimpleDB/Class/Item.pm | ||||
357 | 7 | 10µs | my ($self, $moniker) = @_; | ||
358 | 7 | 37µs | 7 | 34µs | my $class = $self->domain_names->{$moniker}; # spent 34µs making 7 calls to SimpleDB::Class::domain_names, avg 5µs/call |
359 | 7 | 3µs | $class ||= $moniker; | ||
360 | 7 | 36µs | 7 | 577µs | my $d = SimpleDB::Class::Domain->new(simpledb=>$self, item_class=>$class); # spent 577µs making 7 calls to SimpleDB::Class::Domain::new, avg 82µs/call |
361 | 7 | 24µs | return $d; | ||
362 | } | ||||
363 | |||||
364 | #-------------------------------------------------------- | ||||
365 | |||||
366 | =head2 list_domains ( ) | ||||
367 | |||||
368 | Retrieves the list of domain names from your SimpleDB account and returns them as an array reference. | ||||
369 | |||||
370 | =cut | ||||
371 | |||||
372 | # spent 145ms (53µs+144) within SimpleDB::Class::list_domains which was called 2 times, avg 72.3ms/call:
# once (20µs+75.6ms) by main::RUNTIME at line 146 of 05.Domain_and_Item.t
# once (32µs+68.9ms) by main::RUNTIME at line 30 of 05.Domain_and_Item.t | ||||
373 | 2 | 3µs | my ($self) = @_; | ||
374 | 2 | 20µs | 4 | 144ms | my $result = $self->http->send_request('ListDomains'); # spent 144ms making 2 calls to SimpleDB::Client::send_request, avg 72.2ms/call
# spent 15µs making 2 calls to SimpleDB::Class::http, avg 8µs/call |
375 | 2 | 4µs | my $domains = $result->{ListDomainsResult}{DomainName}; | ||
376 | 2 | 2µs | unless (ref $domains eq 'ARRAY') { | ||
377 | $domains = [$domains]; | ||||
378 | } | ||||
379 | 2 | 14µs | return $domains; | ||
380 | } | ||||
381 | |||||
382 | =head1 PREREQS | ||||
383 | |||||
384 | This package requires the following modules: | ||||
385 | |||||
386 | L<JSON> | ||||
387 | L<Sub::Name> | ||||
388 | L<DateTime> | ||||
389 | L<DateTime::Format::Strptime> | ||||
390 | L<Moose> | ||||
391 | L<MooseX::Types> | ||||
392 | L<MooseX::ClassAttribute> | ||||
393 | L<Module::Find> | ||||
394 | L<UUID::Tiny> | ||||
395 | L<Exception::Class> | ||||
396 | L<Memcached::libmemcached> | ||||
397 | L<Clone> | ||||
398 | L<SimpleDB::Client> | ||||
399 | |||||
400 | =head1 TODO | ||||
401 | |||||
402 | Still left to figure out: | ||||
403 | |||||
404 | =over | ||||
405 | |||||
406 | =item * | ||||
407 | |||||
408 | Creating multi-domain objects ( so you can put each country's data into it's own domain, but still search all country-oriented data at once). | ||||
409 | |||||
410 | =item * | ||||
411 | |||||
412 | More exception handling. | ||||
413 | |||||
414 | =item * | ||||
415 | |||||
416 | More tests. | ||||
417 | |||||
418 | =item * | ||||
419 | |||||
420 | All the other stuff I forgot about or didn't know when I designed this thing. | ||||
421 | |||||
422 | =back | ||||
423 | |||||
424 | =head1 SUPPORT | ||||
425 | |||||
426 | =over | ||||
427 | |||||
428 | =item Repository | ||||
429 | |||||
430 | L<http://github.com/plainblack/SimpleDB-Class> | ||||
431 | |||||
432 | =item Bug Reports | ||||
433 | |||||
434 | L<http://rt.cpan.org/Public/Dist/Display.html?Name=SimpleDB-Class> | ||||
435 | |||||
436 | =back | ||||
437 | |||||
438 | =head1 AUTHOR | ||||
439 | |||||
440 | JT Smith <jt_at_plainblack_com> | ||||
441 | |||||
442 | I have to give credit where credit is due: SimpleDB::Class is heavily inspired by L<DBIx::Class> by Matt Trout (and others). | ||||
443 | |||||
444 | =head1 LEGAL | ||||
445 | |||||
446 | SimpleDB::Class is Copyright 2009-2010 Plain Black Corporation (L<http://www.plainblack.com/>) and is licensed under the same terms as Perl itself. | ||||
447 | |||||
448 | =cut | ||||
449 | |||||
450 | 3 | 46µs | 2 | 254µs | # spent 134µs (14+120) within SimpleDB::Class::BEGIN@450 which was called
# once (14µs+120µs) by Class::MOP::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP.pm:103] at line 450 # spent 134µs making 1 call to SimpleDB::Class::BEGIN@450
# spent 120µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:478] |
451 | 1 | 80µs | 2 | 16.5ms | __PACKAGE__->meta->make_immutable; # spent 16.5ms making 1 call to Class::MOP::Class::make_immutable
# spent 11µs making 1 call to SimpleDB::Class::meta |