轉自:http://my.oschina.net/cniiliuqi/blog/67423
1、Example
$redis->pconnect('127.0.0.1', 6379);
$redis->pconnect('127.0.0.1'); // port 6379 by default - same connection like before.
$redis->pconnect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout and would be another connection than the two before.
$redis->pconnect('127.0.0.1', 6379, 2.5, 'x'); // x is sent as persistent_id and would be another connection the the three before.
$redis->pconnect('/tmp/redis.sock'); // unix domain socket - would be another connection than the four before.
2、AUTH password http://redis.readthedocs.org/en/latest/connection/auth.html
寫道 # 設定密碼
redis> CONFIG SET requirepass secret_password # 将密碼設定為 secret_password
OK
redis> QUIT # 退出再連接配接,讓新密碼對用戶端生效
[[email protected]]$ redis
redis> PING # 未驗證密碼,操作被拒絕
(error) ERR operation not permitted
redis> AUTH wrong_password_testing # 嘗試輸入錯誤的密碼
(error) ERR invalid password
redis> AUTH secret_password # 輸入正确的密碼
OK
redis> PING # 密碼驗證成功,可以正常操作指令了
PONG
# 清空密碼
redis> CONFIG SET requirepass "" # 通過将密碼設為空字元來清空密碼
OK
redis> QUIT
$ redis # 重新進入用戶端
redis> PING # 執行指令不再需要密碼,清空密碼操作成功
PONG
3、Redis的PHP字元串執行個體 http://www.yiibai.com/redis/redis_php.html
<?php
//Connecting to Redis server on localhost
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//set the data in redis string
$redis->set("tutorial-name", "Redis tutorial");
// Get the stored data and print it
echo "Stored string in redis:: " + jedis.get("tutorial-name");
?>