$userCache = new Redis(); $conn = $userCache->connect('127.0.0.1','6379'); if(!$conn){ echo "can not connect this Redis server";die; } $userCache->select(1); $userCache->set("db-test",''); $dbNum = $_GET['cc']%16; $userCache->select($dbNum); $userCache->set("db-test",'2333'); $userCache->select(1); echo 'db1:'.$userCache->get("db-test"); $userCache->select($dbNum); echo "db$dbNum:".$userCache->get("db-test"); $userCache->select(15); echo 'db15:'.$userCache->get("db-test");
關於redis切換到指定的數據庫,這裏只是測試html
具體能夠redis
http://www.redis.net.cn/order/3653.html數據庫
查看測試