<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/clock.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -16,9 +16,9 @@ end
 
 namespace :db do
   task :connect do
-    Memoria.new
+    Memoria.data_mapper_setup
   end
-  
+
   desc &quot;Auto migrate the database&quot;
   task :migrate =&gt; :connect do
     DataMapper.auto_migrate!</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,22 @@
-module Memoria  
+module Memoria
   class &lt;&lt; self
-    def new(config_path = &quot;memoria.yml&quot;)
-      @config_path = config_path
-      DataMapper.setup(:default, config[:db])
+    def new(start_clock = true, clock_timeout = 30)
+      data_mapper_setup
+      Clock.run(clock_timeout) if start_clock
       Sinatra::Application
     end
 
-    def config
-      @config ||= YAML.load_file(@config_path)[Sinatra::Application.environment]
+    def data_mapper_setup
+      DataMapper.setup(:default, config[:db])
     end
+
+    protected
+      def config
+        @config ||= YAML.load_file(config_path)[Sinatra::Application.environment]
+      end
+      
+      def config_path
+        @config_path ||= File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;memoria.yml&quot;))
+      end
   end
 end
\ No newline at end of file</diff>
      <filename>app/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,12 +10,11 @@ class Server
   
   include DataMapper::Resource
 
-  has n, :snapshots
-
   property :id,   Serial
   property :name, String, :key =&gt; true
   property :host, String
   property :port, String
+  has n, :snapshots
 
   validates_present :name, :host, :port
   validates_format  :name, :with =&gt; /^[0-9a-z]*$/i
@@ -48,6 +47,7 @@ class Server
     else
       self.snapshots.create :alive =&gt; false, :created_at =&gt; Time.now
     end
+    @stats = nil
   end
 
   def alive?</diff>
      <filename>app/models/server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,12 @@
 class Snapshot
   include DataMapper::Resource
-  belongs_to :server
 
-  property :id,                         Serial
-  property :alive,                      Boolean
-  property :used_memory,                Integer
-  property :total_connections_received, Integer
-  property :connected_clients,          Integer
-  property :total_commands_processed,   Integer
-  property :created_at,                 DateTime
+  property   :id,                         Serial
+  belongs_to :server
+  property   :alive,                      Boolean
+  property   :used_memory,                Integer
+  property   :total_connections_received, Integer
+  property   :connected_clients,          Integer
+  property   :total_commands_processed,   Integer
+  property   :created_at,                 DateTime
 end
\ No newline at end of file</diff>
      <filename>app/models/snapshot.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,11 +2,12 @@ require &quot;rubygems&quot;
 require &quot;sinatra&quot;
 require &quot;dm-core&quot;
 require &quot;dm-validations&quot;
-require &quot;enumerator&quot;
+require &quot;eventmachine&quot;
 require &quot;redis&quot;
 
 $:.unshift &quot;app&quot;
 require &quot;core_ext&quot;
+require &quot;clock&quot;
 require &quot;base&quot;
 require &quot;models&quot;
 require &quot;helpers&quot;</diff>
      <filename>memoria.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ root = File.join(File.dirname(__FILE__), '..')
 
 require &quot;#{root}/memoria&quot;
 
-Memoria.new(File.join(File.dirname(__FILE__), '..', 'memoria.yml'))
+Memoria.new false
 DataMapper.auto_migrate!
 Server.create! :name =&gt; &quot;single&quot;, :host =&gt; &quot;127.0.0.1&quot;, :port =&gt; &quot;6379&quot;
 </diff>
      <filename>spec/env.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cbfea45ea07e9c94d80b126d8b23e5021d40e84c</id>
    </parent>
  </parents>
  <author>
    <name>Luca Guidi</name>
    <email>guidi.luca@gmail.com</email>
  </author>
  <url>http://github.com/jodosha/memoria/commit/64a91c1ac77369f651fbd9feb7ea993be2950544</url>
  <id>64a91c1ac77369f651fbd9feb7ea993be2950544</id>
  <committed-date>2009-06-14T14:27:40-07:00</committed-date>
  <authored-date>2009-06-14T14:27:40-07:00</authored-date>
  <message>Collect statistics in background</message>
  <tree>a6c8361bdaf4147e7573c8402573f37d73e5a805</tree>
  <committer>
    <name>Luca Guidi</name>
    <email>guidi.luca@gmail.com</email>
  </committer>
</commit>
