Closed davidqhr closed 10 years ago
The inefficiency is there for a reason: Wrapper is a temporary scaffolding to allow you to port your code to use a real thread pool. It's not meant to be permanent.
Click the wrong button...
It is painful to modify all the code of redis connection.
$redis.zincrby(ChatLog::distinct_user_key(Date.today), 1, sender_id)
$redis.zincrby(ChatLog::message_count_key, 1, Date.today.strftime('%Y-%m-%d'))
to
$redis.with do |conn|
conn.zincrby(ChatLog::distinct_user_key(Date.today), 1, sender_id)
conn.zincrby(ChatLog::message_count_key, 1, Date.today.strftime('%Y-%m-%d'))
end
Since it provides a wrapper which is a sample way to use the gem without modifing a lot of code. why not an efficient one?
Again, the Wrapper is there to help port your code. It's not meant to be a high-performance replacement / stand-in for the real ConnectionPool API and is documented as such. I want there to be a cost so that people have a reason to use it only temporarily.
ok, I got it.
We use connection_pool in our server.
In fact, the method named
sadd
is one of Redis.connect`s methods which is delegated by ConnectionPool::Wrappe#method_missing.It's more efficient to define the method when method missing.