<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,4 +9,5 @@ TAGS
 public/tmp
 spec/datasets/tmp
 *.tmproj
-cache
\ No newline at end of file
+cache
+.idea
\ No newline at end of file</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 
 === Edge
 
+* Set Radiant::Config to cache info in the Rails.cache [Jim Gay]
 * Markup fixes [Justin Blecher, Alex Wallace]
 * Use Rails for time zone handling [Kunal Shah, Josh French]
 * Allow extensions to declare dependencies [Josh French]
@@ -48,7 +49,7 @@ Cribbs]
 Allan]
 * Don't raise exception on unauthenticated request to /admin/logout.
 [Josh French]
-* Reverse view paths order in extension loader. [Sean Cribbs, Brent
+* Reverse view paths order in extension loader. [Sean Cribbs, Brent 
 Kroeker]
 * Remove obviated Ruby 1.8.7 compatibility patch. [Sean Cribbs]
 * Adjust StandardTags#relative_url_for for case when relative_url_root</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -30,12 +30,17 @@ module Radiant
   #                              for published date on the page edit screen
   class Config &lt; ActiveRecord::Base
     set_table_name &quot;config&quot;
+    after_save :update_cache
 
     class &lt;&lt; self
       def [](key)
         if table_exists?
-          pair = find_by_key(key)
-          pair.value if pair
+          unless Radiant::Config.cache_file_exists?
+            Radiant::Config.ensure_cache_file
+            Radiant::Config.initialize_cache
+          end
+          Radiant::Config.initialize_cache if Radiant::Config.stale_cache?
+          Rails.cache.fetch('Radiant::Config')[key]
         end
       end
 
@@ -50,6 +55,28 @@ module Radiant
       def to_hash
         Hash[ *find(:all).map { |pair| [pair.key, pair.value] }.flatten ]
       end
+      
+      def initialize_cache
+        Radiant::Config.ensure_cache_file
+        Rails.cache.write('Radiant::Config',Radiant::Config.to_hash)
+        Rails.cache.write('Radiant.cache_mtime', File.mtime(Rails.cache.fetch('Radiant.cache_file')))
+      end
+      
+      def cache_file_exists?
+        return false if Rails.cache.fetch('Radiant.cache_file').nil?
+        File.file?(Rails.cache.read('Radiant.cache_file'))
+      end
+      
+      def stale_cache?
+        return true unless Radiant::Config.cache_file_exists?
+        Rails.cache.read('Radiant.cache_mtime') != File.mtime(Rails.cache.read('Radiant.cache_file'))
+      end
+      
+      def ensure_cache_file
+        Radiant::Cache::EntityStore.new if Radiant::Cache.entity_stores.blank?
+        Rails.cache.write('Radiant.cache_file', File.join(Radiant::Cache.entity_stores.first.root,'radiant_config_cache.txt'))
+        File.open(Rails.cache.fetch('Radiant.cache_file'), &quot;wb+&quot;) {|f| f.write('')}
+      end
     end
 
     def value=(param)
@@ -63,5 +90,9 @@ module Radiant
         self[:value]
       end
     end
+    
+    def update_cache
+      Radiant::Config.initialize_cache
+    end
   end
 end</diff>
      <filename>app/models/radiant/config.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ config.action_controller.allow_forgery_protection    = false
 # ActionMailer::Base.deliveries array.
 config.action_mailer.delivery_method = :test
 
-config.gem &quot;rspec&quot;, :version =&gt; &quot;1.2.6&quot;, :lib =&gt; false
-config.gem &quot;rspec-rails&quot;, :version =&gt; &quot;1.2.6&quot;, :lib =&gt; false
+config.gem &quot;rspec-rails&quot;, :version =&gt; &quot;~&gt;1.2.6&quot;, :lib =&gt; false
 config.gem &quot;webrat&quot;, :version =&gt; &quot;~&gt;0.4.4&quot;, :lib =&gt; false
 config.gem &quot;cucumber&quot;, :version =&gt; &quot;~&gt;0.3.9&quot;, :lib =&gt; false
\ No newline at end of file</diff>
      <filename>config/environments/test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,10 +2,14 @@ require File.dirname(__FILE__) + &quot;/../../spec_helper&quot;
 
 describe Radiant::Config do
   before :each do
+    Radiant::Config.initialize_cache
     @config = Radiant::Config
     set('test', 'cool')
     set('foo', 'bar')
   end
+  after :each do 
+    Radiant::Cache.clear
+  end
 
   describe &quot;before the table exists, as in case of before bootstrap&quot; do
     before :each do
@@ -22,6 +26,41 @@ describe Radiant::Config do
       @config['test'] = 'cool'
     end
   end
+  
+  it &quot;should create a cache of all records in a hash with Radiant::Config.initialize_cache&quot; do
+    Rails.cache.read('Radiant::Config').should == Radiant::Config.to_hash
+  end
+  
+  it &quot;should recreate the cache after a record is saved&quot; do
+    Radiant::Config.create!(:key =&gt; 'cache', :value =&gt; 'true')
+    Rails.cache.read('Radiant::Config').should == Radiant::Config.to_hash
+  end
+  
+  it &quot;should update the mtime on the cache file after a record is saved&quot; do
+    File.should_receive(:open).with(Rails.cache.read('Radiant.cache_file'), &quot;wb+&quot;).at_least(:once)
+    Radiant::Config['mtime'] = 'now'
+  end
+  
+  it &quot;should record the cache file mtime when the cache is initialized&quot; do
+    Radiant::Config.initialize_cache
+    Rails.cache.read('Radiant.cache_mtime').should == File.mtime(Rails.cache.fetch('Radiant.cache_file'))
+  end
+  
+  it &quot;should create a cache file when initializing the cache&quot; do
+    Radiant::Cache.clear
+    File.exist?(File.join(Radiant::Cache.entity_stores.first.root,'radiant_config_cache.txt')).should be_false
+    Radiant::Config.initialize_cache
+    File.file?(File.join(Radiant::Cache.entity_stores.first.root,'radiant_config_cache.txt')).should be_true
+  end
+  
+  it &quot;should find the value in the cache with []&quot; do
+    Radiant::Config['test'].should === Rails.cache.read('Radiant::Config')['test']
+  end
+  
+  it &quot;should set the value in the database with []=&quot; do
+    Radiant::Config['new-db-key'] = 'db-value'
+    Radiant::Config.find_by_key('new-db-key').value.should == 'db-value'
+  end
 
   it &quot;should return the value of a key with the bracket accessor&quot; do
     @config['test'].should == 'cool'
@@ -68,6 +107,6 @@ describe Radiant::Config do
   def set(key, value)
     setting = Radiant::Config.find_by_key(key)
     setting.destroy if setting
-    Radiant::Config.new(:key =&gt; key, :value =&gt; value).save
+    Radiant::Config.create!(:key =&gt; key, :value =&gt; value)
   end
 end
\ No newline at end of file</diff>
      <filename>spec/models/radiant/config_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d7fd64b1fe7345b9e2cbd49fc5ef48da3cf2d8a0</id>
    </parent>
  </parents>
  <author>
    <name>Jim Gay</name>
    <email>jim@saturnflyer.com</email>
  </author>
  <url>http://github.com/radiant/radiant/commit/4f2ba63484ce8ef7ef3b3f482317eea7d87879d5</url>
  <id>4f2ba63484ce8ef7ef3b3f482317eea7d87879d5</id>
  <committed-date>2009-06-29T18:40:46-07:00</committed-date>
  <authored-date>2009-03-14T20:15:40-07:00</authored-date>
  <message>move Radiant::Config to Rails.cache</message>
  <tree>8b72ab4d5cdb201e449af91a7d96efeda6e8f313</tree>
  <committer>
    <name>Jim Gay</name>
    <email>jim@saturnflyer.com</email>
  </committer>
</commit>
