Code:
$cmd = "*3\r\n$3\r\nSET\r\n$3\r\nfoo\r\n$3\r\nbar\r\n"; // set foo bar$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);socket_connect($socket, ‘127.0.0.1‘, 6379);$flag = socket_write($socket,$cmd,strlen($cmd));eee($flag);
Reids protocol uses text protocol
Specific reference http://www.redisdoc.com/en/latest/topic/protocol.html
In addition to the native TCP protocol, redis also designedInline commandsTo operate redis like in redis-cli
Redis: Text Protocol
Memcached: text protocol + binary Protocol
HTTP: Text Protocol
Gearman: Binary Protocol
MySQL: Binary Protocol
Binary Protocol: smaller data volume, higher efficiency, but not easy to expand, poor readability
Text Protocol: multiple data transmission, good readability, and easy scalability
Predis is an extension that uses the native socket method to operate redis.
Simple understanding of the Protocol
Use SOCKET to operate redis