zoukankan      html  css  js  c++  java
  • 1.3redis小结--配置php reids拓展

    1.执行php文件 输出phpinfo(); 

    <?php 
    phpinfo();

    2.根据PHPinfo的信息确定需要下载的 php_redis.dll , php_igbinary.dll 版本

    php_redis.dll下载链接: http://windows.php.net/downloads/pecl/releases/redis/2.2.7/

    php_igbinary.dll 下载链接: http://windows.php.net/downloads/pecl/releases/igbinary

     3.将php_redis.dll , php_igbinary.dll 拓展放到php 下的ext文件夹中

    4.php.ini文件中添加redis拓展

    ; php-redis
    extension=php_igbinary.dll  
    extension=php_redis.dll 

     5.查看redis拓展是否成功添加

    6.php操作redis

    <?php 
    
    $redis = new Redis();
    $redis->connect('127.0.0.1', 6379);
    //查看服务是否运行
    echo "Server is running: " . $redis->ping();

     6.1.Redis PHP String(字符串) 实例

    <?php
       //连接本地的 Redis 服务
       $redis = new Redis();
       $redis->connect('127.0.0.1', 6379);
       echo "Connection to server sucessfully";
       //设置 redis 字符串数据
       $redis->set("tutorial-name", "Redis tutorial");
       // 获取存储的数据并输出
       echo "Stored string in redis:: " . $redis->get("tutorial-name");

     6.2Redis PHP List(列表) 实例

    <?php
       //连接本地的 Redis 服务
       $redis = new Redis();
       $redis->connect('127.0.0.1', 6379);
       echo "Connection to server sucessfully";
       //存储数据到列表中
       $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);

     6.3Redis PHP Keys 实例

    <?php
       //连接本地的 Redis 服务
       $redis = new Redis();
       $redis->connect('127.0.0.1', 6379);
       echo "Connection to server sucessfully";
       // 获取数据并输出
       $arList = $redis->keys("*");
       echo "Stored keys in redis:: ";
       print_r($arList);
  • 相关阅读:
    js对象排序
    路由懒加载优化
    RabbitMQ---1、安装与部署
    RabbitMQ入门教程系列
    c#项目代码风格要求
    C#RabbitMQ基础学习笔记
    C# 协变和逆变
    获取当前系统的基本信息
    html制作chm格式开源文档
    WPF: RenderTransform特效
  • 原文地址:https://www.cnblogs.com/mike1314/p/8508201.html
Copyright © 2011-2022 走看看