From 5b4b808cd09e92a88843b1bf116dc9472754744a Mon Sep 17 00:00:00 2001 From: Vladimir Andrijevik Date: Wed, 3 Mar 2010 05:18:18 +0800 Subject: [PATCH] Conform to ActiveSupport::Cache#delete's interface in Memcached::Rails. --- lib/memcached/rails.rb | 4 ++-- test/unit/rails_test.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/memcached/rails.rb b/lib/memcached/rails.rb index f931674..9681cda 100644 --- a/lib/memcached/rails.rb +++ b/lib/memcached/rails.rb @@ -76,8 +76,8 @@ class Memcached end # Wraps Memcached#delete so that it doesn't raise. - def delete(key) - super + def delete(key, expiry=0) + super(key) rescue NotFound end diff --git a/test/unit/rails_test.rb b/test/unit/rails_test.rb index 6bebf86..20b1812 100644 --- a/test/unit/rails_test.rb +++ b/test/unit/rails_test.rb @@ -41,6 +41,13 @@ class RailsTest < Test::Unit::TestCase end end + def test_delete_with_two_arguments + assert_nothing_raised do + @cache.delete(key, 5) + assert_nil(@cache.get(key)) + end + end + def test_bracket_accessors @cache[key] = @value result = @cache[key]