redis PHP 操作笔记

<?php
    //1111111111111111
    //连接本地的 Redis 服务
    //   $redis = new Redis();
    //   $redis->connect('127.0.0.1', 6379);
    //   //echo "Connection to server successfully";
    //          //查看服务是否运行
    //   echo "Server is running: " . $redis->ping();

    //phpinfo()
    
    
    //222222222222222222222222
    //连接本地的 Redis 服务 Redis PHP String(字符串) 实例
    //$redis = new Redis();
    //$redis->connect('127.0.0.1', 6379);
    //echo "Connection to server successfully";
    //设置 redis 字符串数据
    //$redis->set("config_host", "wwww.baidu.com");
  // 获取存储的数据并输出
     //echo $redis->get("tutorial-name");
    //echo "config_host:: " . $redis->get("config_host");//获取

    
    //33333333333333333333333333
    //连接本地的 Redis 服务 Redis PHP List(列表) 实例
//   $redis = new Redis();
//   $redis->connect('127.0.0.1', 6379);
//   echo "Connection to server successfully";
//   //存储数据到列表中
//   $redis->lpush("tutorial-list", "Redis");
//   $redis->lpush("tutorial-list", "Mongodb");
//   $redis->lpush("tutorial-list", "Mysql");
//   // 获取存储的数据并输出
//   $arList = $redis->lrange("tutorial-list", 0 ,5);
//   echo "Stored string in redis";
//   print_r($arList);
        
        
        //44444444444444444444444
        //Redis PHP Keys 实例 打印出全部的key
        //连接本地的 Redis 服务
    //   $redis = new Redis();
    //   $redis->connect('127.0.0.1', 6379);
    //   echo "Connection to server successfully";
    //   // 获取数据并输出
    //   $arList = $redis->keys("*");
    //   echo "Stored keys in redis:: ";
    //   print_r($arList);
    
    
    
    
    
    /***
    总结
      $redis = new Redis();//实例化
      $redis->connect('127.0.0.1', 6379);//连接
      $redis->set("config_host", "wwww.baidu.com");//设置字符串
      $redis->get("config_host");//读取字符串
      
      
      // 存列表
      //存储数据到列表中
      //   $redis->lpush("tutorial", "Redis");
      //   $redis->lpush("tutorial", "Mongodb");
      //   $redis->lpush("tutorial", "Mysql");
      
      
      //   // 获取存储的数据并输出
      //   $arList = $redis->lrange("tutorial", 0 ,5);
      
      //   // 获取数据并输出
      //   $arList = $redis->keys("*");
      
      
      
      
    
    **/



?>
原文地址:https://www.cnblogs.com/shaozhu520/p/13577124.html