Skip to content

Instantly share code, notes, and snippets.

@fredjean
Created July 29, 2009 04:32
Show Gist options
  • Save fredjean/157871 to your computer and use it in GitHub Desktop.
Save fredjean/157871 to your computer and use it in GitHub Desktop.
if RUBY_PLATFORM =~ /java/i
# Based on instructions from http://www.mikeperham.com/2009/03/03/using-memcache-client-16x-in-rails-23/
# Brain surgery to use our own version of memcache-client without
# having to modify activesupport directly.
# Unload any previous instance of the class
if Object.const_defined? :MemCache
Object.instance_eval { remove_const :MemCache }
end
# Ensure that the memcache-client path is at the front of the loadpath
$LOAD_PATH.each do |path|
if path =~ /jruby-memcache-client/
$LOAD_PATH.delete(path)
$LOAD_PATH.unshift(path)
end
end
# If Ruby thinks it's already loaded memcache.rb, force
# a reload otherwise just require.
if $".find { |file| file =~ /\Amemcache.rb\Z/ }
load 'memcache.rb'
else
require 'memcache'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment