Skip to content

Commit

Permalink
Injecting expiry times in seconds and respecting them
Browse files Browse the repository at this point in the history
  • Loading branch information
benschwarz committed Jun 21, 2008
1 parent bfbcd43 commit 35955ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/merb-cache/cache_store.rb
Expand Up @@ -38,6 +38,7 @@ def get(key)
# Put, like a HTTP request
# Its the web kids
def put(key, data, expiry)
expiry = expiry * 60 # expiry = 1 becomes 60
@store.put(key, data, expiry)
Merb.logger.info("cache: set (#{key})")
end
Expand Down
6 changes: 6 additions & 0 deletions spec/cache_store_spec.rb
Expand Up @@ -19,6 +19,12 @@
it "should expire a cache" do
@cache.expire!("a-key")
end

it "should set validity in minutes" do
@cache.put("c-key", "data", 1)
sleep 2 # Seconds
@cache.cached?("c-key").should be_true
end
end

describe "store keys" do
Expand Down

0 comments on commit 35955ba

Please sign in to comment.