Created
September 17, 2013 20:56
-
-
Save arthurnn/6600510 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/identity_cache/memcached_adapter.rb b/lib/identity_cache/memcached_adapter.rb | |
index 9aa9e56..c817dd8 100644 | |
--- a/lib/identity_cache/memcached_adapter.rb | |
+++ b/lib/identity_cache/memcached_adapter.rb | |
@@ -17,14 +17,11 @@ module IdentityCache | |
super(servers, opts.merge(support_cas: true)) | |
end | |
- %w{delete incr decr append prepend}.each do |meth| | |
- define_method(meth) do |*args| | |
- begin | |
- super(*args) | |
- rescue *NONFATAL_EXCEPTIONS | |
- end | |
- end | |
- end | |
+ def delete(*args); without_raise { super(*args) }; end | |
+ def incr(*args); without_raise { super(*args) }; end | |
+ def decr(*args); without_raise { super(*args) }; end | |
+ def append(*args); without_raise { super(*args) }; end | |
+ def prepend(*args); without_raise { super(*args) }; end | |
def get(key) | |
value = super(key) | |
@@ -65,5 +62,11 @@ module IdentityCache | |
false | |
end | |
+ private | |
+ def without_raise | |
+ yield | |
+ rescue *NONFATAL_EXCEPTIONS | |
+ end | |
+ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment