Skip to content

Commit

Permalink
Merge branch 'master' of git://Spinners.local
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neighman committed Jun 22, 2008
2 parents 55bd333 + a028352 commit ca7b9e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions lib/merb-cache/cache_stores/mintcache_store.rb
Expand Up @@ -41,16 +41,15 @@ def get(key)
return nil
end

def put (key, value, expiry = nil)
def put (key, value, expiry = 0)
# Regular cache set
expiry = expiry ? expiry : 0
@memcache.set key, value, expiry

# Set the data to a seperate key that has a long expiry.
# When the cache that is set above expires, this one can
# steal the show - unless the data really isn't as hot as you'd
# like to think it was – Then you're fucked.
validity_expiry = (expiry * 2) * 60
validity_expiry = (expiry * 2)
@memcache.set("#{key}_validity", (Time.now + expiry), validity_expiry)
@memcache.set("#{key}_data", value, validity_expiry)
end
Expand Down
9 changes: 4 additions & 5 deletions spec/mintcache_store_spec.rb
Expand Up @@ -25,7 +25,7 @@
end

it "should respond to expire" do
@store.public_methods.should include "expire!"
@store.public_methods.should include("expire!")
end

it "should store a key" do
Expand Down Expand Up @@ -62,10 +62,9 @@
end

it "should store the validity key for double the amount of time of the initial expiry" do
pending "Need a brain to write this"
@store.put("expiry_key_spec", "data", 1)
expiry_time = @store.get("expiry_key_spec_validity")
(expiry_time).should eql "120"
expiry = Time.now + 60
@store.put("expiry_key_spec", "regular cache data", 60)
@store.get("expiry_key_spec_validity").to_s.should eql expiry.to_s
end

it "should store a third key to keep the data for a longer expiry time" do
Expand Down

0 comments on commit ca7b9e4

Please sign in to comment.