<?php header('content-type:text/html;chaeset=utf-8'); $redis = new Redis(); $redis->connect('127.0.0.1', 6379); echo "Connection to server sucessfully"; //check whether server is running or not echo "Server is running: ".$redis->ping(); echo '<pre>'; // 缓存数据 $redis->set('cache-key', json_encode([ 'data-list' => '这是个缓存数据~' ]), JSON_UNESCAPED_UNICODE); echo "字符串缓存成功~"; echo '<pre>'; // 获取缓存数据 $data = $redis->get('cache-key'); echo "读取缓存数据为: "; echo '<pre>'; print_r(json_decode($data,true)); ?>