Permalink
Browse files

Remove traces of optional thread safety.

  • Loading branch information...
1 parent 578c01f commit 15c3c5a19bd7128f6082c7217b66e1b7f41ad222 @djanowski djanowski committed Mar 13, 2012
Showing with 5 additions and 49 deletions.
  1. +4 −8 README.md
  2. +0 −38 benchmarking/thread_safety.rb
  3. +0 −2 lib/redis/errors.rb
  4. +1 −1 test/thread_safety_test.rb
View
@@ -121,15 +121,11 @@ You can use `MULTI/EXEC` to run arbitrary commands in an atomic fashion:
redis.incr "baz"
end
-## Multithreaded Operation
+## Multi-threading
-Starting with redis-rb 2.2.0, the client is thread-safe by default. To use
-earlier versions safely in a multithreaded environment, be sure to initialize
-the client with `:thread_safe => true`. Thread-safety can be explicitly
-disabled for versions 2.2 and up by initializing the client with `:thread_safe
-=> false`.
-
-See the tests and benchmarks for examples.
+Starting with version 2.2.0, the client is thread-safe by default. To use
+earlier versions safely in a multi-threaded environment, be sure to initialize
+the client with `:thread_safe => true`.
## Alternate drivers
@@ -1,38 +0,0 @@
-# Run with
-#
-# $ ruby -Ilib benchmarking/thread_safety.rb
-#
-
-begin
- require "bench"
-rescue LoadError
- $stderr.puts "`gem install bench` and try again."
- exit 1
-end
-
-require "redis"
-
-def stress(redis)
- redis.flushdb
-
- n = (ARGV.shift || 2000).to_i
-
- n.times do |i|
- key = "foo:#{i}"
- redis.set key, i
- redis.get key
- end
-end
-
-thread_unsafe = Redis.new(:thread_safe => false)
-thread_safe = Redis.new(:thread_safe => true)
-
-benchmark "Thread-unsafe" do
- stress(thread_unsafe)
-end
-
-benchmark "Thread-safe" do
- stress(thread_safe)
-end
-
-run 10
View
@@ -8,8 +8,6 @@ class ProtocolError < BaseError
def initialize(reply_type)
super(<<-EOS.gsub(/(?:^|\n)\s*/, " "))
Got '#{reply_type}' as initial reply byte.
- If you're running in a multi-threaded environment, make sure you
- pass the :thread_safe option when initializing the connection.
If you're in a forking environment, such as Unicorn, you need to
connect to Redis after forking.
EOS
@@ -7,7 +7,7 @@
end
test "thread safety" do
- redis = Redis.connect(OPTIONS.merge(:thread_safe => true))
+ redis = Redis.connect(OPTIONS)
redis.set "foo", 1
redis.set "bar", 2

0 comments on commit 15c3c5a

Please sign in to comment.