Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "timeout"
- class MemCache
- alias_method :old_get, :get
- alias_method :old_set, :set
- alias_method :old_incr, :incr
- alias_method :old_add, :add
- alias_method :old_delete, :delete
- alias_method :old_get_multi, :get_multi
- def get(key, raw = false, timeout = 1.0)
- Timeout::timeout(timeout) do
- old_get(key, raw)
- end
- rescue Timeout::Error
- nil
- end
- end
- def set(key, value, expiry = 0, raw = false, timeout = 1.0)
- Timeout::timeout(timeout) do
- old_set(key, value, expiry, raw)
- end
- end
Add Comment
Please, Sign In to add comment