<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -73,23 +73,6 @@ module Cachetastic
       end
       
       private
-      # If the expiry time is set to 60 minutes and the expiry_swing time is set to
-      # 15 minutes, this method will return a number between 45 minutes and 75 minutes.
-      def calculate_expiry_time(expiry_time) # :doc:
-        expiry_time = self.default_expiry if expiry_time.nil?
-        exp_swing = self.expiry_swing
-        if exp_swing &amp;&amp; exp_swing != 0
-          swing = rand(exp_swing.to_i)
-          case rand(2)
-          when 0
-            expiry_time = (expiry_time.to_i + swing)
-          when 1
-            expiry_time = (expiry_time.to_i - swing)
-          end
-        end
-        expiry_time
-      end
-      
       def define_accessor(key)
         instance_eval(%{
           def #{key}</diff>
      <filename>lib/cachetastic/adapters/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,8 +17,8 @@ module Cachetastic
         return val
       end # get
       
-      def set(key, value, expiry_time = nil)
-        so = Cachetastic::Cache::StoreObject.new(key, value, calculate_expiry_time(expiry_time).from_now)
+      def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry)
+        so = Cachetastic::Cache::StoreObject.new(key, value, expiry_time.from_now)
         path = file_path(key)
         ::File.open(path, 'w') {|f| f.write marshal(so)}
         value</diff>
      <filename>lib/cachetastic/adapters/file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,8 +11,8 @@ module Cachetastic
         @_store[key]
       end # get
       
-      def set(key, value, expiry_time = nil)
-        so = Cachetastic::Cache::StoreObject.new(key, value, calculate_expiry_time(expiry_time).from_now)
+      def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry)
+        so = Cachetastic::Cache::StoreObject.new(key, value, expiry_time.from_now)
         @_store[key] = marshal(so)
         value
       end # set</diff>
      <filename>lib/cachetastic/adapters/local_memory.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,8 +22,8 @@ module Cachetastic
         connection.get(transform_key(key), false)
       end # get
       
-      def set(key, value, expiry_time = 0)
-        connection.set(transform_key(key), marshal(value), calculate_expiry_time(expiry_time), false)
+      def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry)
+        connection.set(transform_key(key), marshal(value), expiry_time, false)
       end # set
       
       def delete(key)</diff>
      <filename>lib/cachetastic/adapters/memcached.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,7 @@ module Cachetastic
       
       def set(key, value, expiry_time = nil)
         do_with_logging(:set, key) do
-          self.adapter.set(key, value, expiry_time)
+          self.adapter.set(key, value, calculate_expiry_time(expiry_time))
         end
       end # set
       
@@ -53,6 +53,23 @@ module Cachetastic
       end
       
       private
+      # If the expiry time is set to 60 minutes and the expiry_swing time is set to
+      # 15 minutes, this method will return a number between 45 minutes and 75 minutes.
+      def calculate_expiry_time(expiry_time) # :doc:
+        expiry_time = self.adapter.default_expiry if expiry_time.nil?
+        exp_swing = self.adapter.expiry_swing
+        if exp_swing &amp;&amp; exp_swing != 0
+          swing = rand(exp_swing.to_i)
+          case rand(2)
+          when 0
+            expiry_time = (expiry_time.to_i + swing)
+          when 1
+            expiry_time = (expiry_time.to_i - swing)
+          end
+        end
+        expiry_time
+      end
+      
       def handle_store_object(key, val, &amp;block)
         if val.is_a?(Cachetastic::Cache::StoreObject)
           if val.expired?</diff>
      <filename>lib/cachetastic/cache.rb</filename>
    </modified>
    <modified>
      <diff>@@ -90,23 +90,6 @@ describe Cachetastic::Adapters do
       
     end
     
-    describe 'calculate_expiry_time' do
-      
-      it 'should properly +/- swing to the expiry time' do
-        configatron.temp do
-          configatron.cachetastic.defaults.expiry_swing = 15
-          configatron.cachetastic.defaults.default_expiry = 60
-          Cachetastic::Adapters::Base.send(:public, :calculate_expiry_time)
-          adapter = Cachetastic::Adapters::Base.new(CarCache)
-          10.times do
-            adapter.calculate_expiry_time(60).should &gt;= 45
-            adapter.calculate_expiry_time(60).should &lt;= 75
-          end
-        end
-      end
-      
-    end
-    
   end
   
   ['LocalMemory', 'File', 'Memcached'].each do |adapter|</diff>
      <filename>spec/cachetastic/adapters/base_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,6 +40,26 @@ describe Cachetastic::Cache do
     
   end
   
+  describe 'calculate_expiry_time' do
+    
+    it 'should properly +/- swing to the expiry time' do
+      configatron.temp do
+        configatron.cachetastic.defaults.expiry_swing = 15
+        configatron.cachetastic.defaults.default_expiry = 60
+        SimpleCache.class_eval do
+          class &lt;&lt; self
+            public :calculate_expiry_time
+          end
+        end
+        10.times do
+          SimpleCache.calculate_expiry_time(60).should &gt;= 45
+          SimpleCache.calculate_expiry_time(60).should &lt;= 75
+        end
+      end
+    end
+    
+  end
+  
   
   describe 'logging' do
     </diff>
      <filename>spec/cachetastic/cache_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>92d2aafeae0115809813f4f639efc72efa26ea34</id>
    </parent>
  </parents>
  <author>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </author>
  <url>http://github.com/markbates/cachetastic/commit/5e1a5e5478750b0c488eef5b9cb705dc9cc637c2</url>
  <id>5e1a5e5478750b0c488eef5b9cb705dc9cc637c2</id>
  <committed-date>2009-06-05T11:54:16-07:00</committed-date>
  <authored-date>2009-06-05T11:54:16-07:00</authored-date>
  <message>Moved calculate_expiry_time from adapters into caches, that way adapters don't have to each deal with it</message>
  <tree>93948ae481c48476351cfae38f1673391ced5748</tree>
  <committer>
    <name>Mark Bates</name>
    <email>mark@markbates.com</email>
  </committer>
</commit>
