Skip to content

Commit c175a76

Browse files
authored
Merge pull request #97 from JuliaDatabases/tan/io
fix: improve command execution speed
2 parents cd48768 + c358351 commit c175a76

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/connection.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ function SubscriptionConnection(parent::SubscribableConnection)
101101
end
102102

103103
function on_connect(conn::RedisConnectionBase)
104+
# disable nagle and enable quickack to speed up the usually small exchanges
105+
Sockets.nagle(conn.socket, false)
106+
Sockets.quickack(conn.socket, true)
107+
104108
conn.password != "" && auth(conn, conn.password)
105109
conn.db != 0 && select(conn, conn.db)
106110
conn

src/parser.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ end
8888

8989
function execute_command_without_reply(conn::RedisConnectionBase, command)
9090
is_connected(conn) || throw(ConnectionException("Socket is disconnected"))
91-
lock(conn.socket.lock) do
92-
pack_command(conn.socket, command)
91+
iob = IOBuffer()
92+
pack_command(iob, command)
93+
lock(conn.socket.lock) do
94+
write(conn.socket, take!(iob))
9395
end
9496
end
9597

0 commit comments

Comments
 (0)