Lostsoul
Lostsoul

Reputation: 26001

How can Jedis connect to a redis server using a socket connection?

I'm having problems figuring out how to use the Jedis library to connect to a redis socket connection.

I know how to connect through a network port:

Jedis jedis = new Jedis("localhost");
//Jedis jedis = new Jedis(unix_socket_path="/tmp/redis.sock");

But the socket connection(second in the list) doesn't work. The commands looked simlair to redis-py(python client) but when I tried the same syntax it didn't work. I also looked through the jedis sourcecode on github but couldn't see anything. Any ideas?

Upvotes: 1

Views: 2987

Answers (2)

uglide
uglide

Reputation: 1723

Modern versions of Jedis support UNIX domain sockets through custom Socket factories. Here is an example of how to use it.

Upvotes: 0

Didier Spezia
Didier Spezia

Reputation: 73216

I don't think Jedis support unix domain sockets.

The constructor with a single parameter only accepts a hostname (using default TCP port).

Java is portable. It is supposed to provide the same API on different platforms. Unix domain sockets are specific to Unix/Linux. So the Java standard API does not support unix domain sockets. There are separate Java packages for this, but AFAIK, Jedis do not use them.

Upvotes: 3

Related Questions