怎么在thinkphp5中使用redis缓存新增的数据

本篇文章为大家展示了怎么在thinkphp5中使用redis缓存新增的数据,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

找到该文件
thinkphp/library/think/cache/driver/Redis.php
进行新增方法

在这里 我就举例几个 如何添加 添加的方法查看 redis教程

怎么在thinkphp5中使用redis缓存新增的数据

/**
   * 返回列表中指定区间内的元素
   * */
  public function lrange($key,$start,$end){

    return $this->handler->lrange($key,$start,$end);

  }
  /**
   * 在list左边新增元素
   * */
  public function lpush($key,$value){

    return $this->handler->lPush($key,$value);

  }

  /**
   * 在list右边新增元素
   * */
  public function rpush($key,$value){

    return $this->handler->rPush($key,$value);

  }

  /**
   * 返回并移除列表中的第一个元素
   * */
  public function lpop($key){

    return $this->handler->lPop($key);

  }

  /**
   * 返回并移除列表的最后一个元素。
   * */
  public function rpop($key){

    return $this->handler->rPop($key);

  }

如果还需要添加其他的方法 根据手册某个方法以及传值
去修改$this->handler-> 后面的方法函数

上述内容就是怎么在thinkphp5中使用redis缓存新增的数据,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。