1. Download Redis zip package for Windows: https://github.com/ServiceStack/redis-windows
2. Copy redis.windos.conf to master.conf and slave.conf.
3. master.conf
port: 6379
4. slave.conf
port: 6378
slaveof 127.0.0.1 6379
5. Start Redis
redis-server.exe master.conf
redis-server.exe slave.conf
6. Write to master and read from slave:
-
public class RedisTest {
-
public static void main(String[] args) {
-
Jedis master = new Jedis("127.0.0.1", 6379);
-
Jedis slave = new Jedis("127.0.0.1", 6378);
-
-
master.set("name", "test");
-
-
System.out.println(master.get("name"));
-
System.out.println(slave.get("name"));
-
-
master.close();
-
slave.close();
-
}
-
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10742815/viewspace-2135456/
,如需转载,请注明出处,否则将追究法律责任。