[moka同学笔记]redis练习Demo
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[moka同学笔记]redis练习Demo相关的知识,希望对你有一定的参考价值。
<?php /** * Created by PhpStorm. * User: moka同学 * Date: 2017/3/13 * Time: 10:54 */ echo ‘Hello redis‘.‘<br>‘; $redis = new Redis(); $redis->connect("127.0.0.1","6379"); //demo1 /*$redis->set("name","This is firewater!"); echo $redis->get("name");*/ //demo2 /*$redis->set(‘tutorial-name‘,‘redis tutorial‘); echo "test:".$redis->get(‘tutorial-name‘);*/ //list /*$redis->lPush(‘demo-list‘,‘Redis‘); $redis->lPush(‘demo-list‘,‘Mongodb‘); $redis->lPush(‘demo-list‘,‘mysql‘); $arList = $redis->lRange(‘demo-list‘,0,5); echo ‘保存的demo-list:‘.‘<br>‘; print_r($arList);*/ /*$aList = $redis->keys("*"); echo ‘保存‘.‘<br>‘; print_r($aList);*/ //hash类型 /*$redis->delete(‘people‘); $redis->hSet(‘people‘,‘name‘,‘mingming‘); $redis->hSet(‘people‘,‘age‘,25); $redis->hSet(‘people‘,‘gender‘,1); $val = $redis->hGet(‘people‘,‘age‘); var_dump($val); $val = $redis->hMGet(‘people‘,array(‘name‘,‘age‘)); var_dump($val);*/ //sort set 类型,排行榜 $redis->delete(‘name‘); $redis->zAdd(‘name‘,100,‘xiaoming‘); $redis->zAdd(‘name‘,90,‘xiaohong‘); $redis->zAdd(‘name‘,96,‘xiaobai‘); $val = $redis->zRange(‘name‘,0,-1); //从低到高 var_dump($val); $val = $redis->zRevRange(‘name‘,0,-1);//从高到低 var_dump($val);
以上是关于[moka同学笔记]redis练习Demo的主要内容,如果未能解决你的问题,请参考以下文章
[moka同学笔记]yii2.0 dropdownlist的简单使用
[moka同学笔记]WINDOWS中cmd的切换目录cd命令失效