LoginSignup
7
7

More than 5 years have passed since last update.

PHPからRedisを使うサンプル

Posted at

PHPからRedisを使うことになった。
せっかくなのでメモを残しておく

sample.php
<?php
$redis = new Redis();
$redis->connect("127.0.0.1",6379);

 //hogeをKeyにしてデータをセットする
$redis->set("hoge","hoge-redis");

 //データを取り出す
$res = $redis->get("hoge");
echo $res;

//その結果、ブラウザには「hoge-redis」と表示される
?>

参考サイト
redisドキュメント日本語訳¶
http://redis.shibu.jp/

phpredis
https://github.com/phpredis/phpredis#installation

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7