Browse Source

cache the collection handle objects

Joel Berger 11 years ago
parent
commit
b4d459a949
1 changed files with 2 additions and 2 deletions
  1. 2 2
      frameworks/Perl/mojolicious/app.pl

+ 2 - 2
frameworks/Perl/mojolicious/app.pl

@@ -23,8 +23,8 @@ app->config->{hypnotoad}{workers} = app->config->{workers};
 
 helper mango   => sub { state $mango = Mango->new('mongodb://'. shift->config->{database_host}) };
 helper db      => sub { state $db = shift->mango->db('hello_world') };
-helper world   => sub { shift->db->collection('world') };
-helper fortune => sub { shift->db->collection('fortune') };
+helper world   => sub { state $world = shift->db->collection('world') };
+helper fortune => sub { state $fortune = shift->db->collection('fortune') };
 
 # JSON::XS renderer