手写redis客户端
一、RESP通信协议 Redis Serialization Protocol (Redis序列化协议). 特点:容易实现、解析快、可读性强 以\r\n分割数据. 二、撸代码 package com.dongnao.demo; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; /** * Created by crescendo.tian on 2018/8/27. */ public class TqRedis { private Socket socket; private OutputStream write; private InputStream read; public TqRedis(String host, int port) throws IOException { socket = new Socket(host, port); } public void set(String key, String val) throws IOException { StringBuffer sb = new StringBuffer(); sb.append( "*3").append("\r\n"); //