thinkphp5 redis缓存新增方法实例讲解

 4646

这篇文章主要介绍了thinkphp5redis缓存新增方法实例讲解,redis是项目中最常用的缓存,有正在使用的同学可以看下

找到该文件

thinkphp/library/think/cache/driver/Redis.php

进行新增方法

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


在这里插入图片描述


  1. /**
  2.  * 返回列表中指定区间内的元素
  3.  **/
  4. public function lrange($key,$start,$end){
  5.     return $this->handler->lrange($key,$start,$end);
  6. }
  7.  
  8. /**
  9.  * 在list左边新增元素
  10.  **/
  11. public function lpush($key,$value){
  12.     return $this->handler->lPush($key,$value);
  13. }
  14.  
  15. /**
  16.  * 在list右边新增元素
  17.  **/
  18. public function rpush($key,$value){
  19.     return $this->handler->rPush($key,$value);
  20. }
  21.  
  22. /**
  23.  * 返回并移除列表中的第一个元素
  24.  **/
  25. public function lpop($key){
  26.     return $this->handler->lPop($key);
  27. }
  28.  
  29. /**
  30.  * 返回并移除列表的最后一个元素。
  31.  **/
  32. public function rpop($key){
  33.     return $this->handler->rPop($key);
  34. }

如果还需要添加其他的方法 根据手册某个方法以及传值

去修改$this->handler-> 后面的方法函数



本文网址:https://www.zztuku.com/index.php/detail-8749.html
站长图库 - thinkphp5 redis缓存新增方法实例讲解
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐

    Photoshop打造超酷的火焰汽车