Key设计

全局相关的key:

表名

global

列名

操作

备注

Global:userid

incr

产生全局的userid

Global:postid

Incr

产生全局的postid

用户相关的key(表):

表名

user

Userid

Username

Password

Authsecret

3

Test3

1111111

#U*Q(%_

用户注册:

 /**
* 用户注册信息
*/
public function userRegister()
{
$redis = RedisInstance::MasterInstance();
$redis->select(10);
$username = 'tinywan'.mt_rand(0000,8888);
$password = '123456';
if($redis->get('user:username:'.$username.':userid')){
exit('该用户名没有被使用');
}
//获取全局userId
$userId = $redis->incr('global:userid');
$redis->set('user:userId:'.$userId.':username',$username);
$redis->set('user:userId:'.$userId.':password',$password);
$redis->set('user:username:'.$username.':userid',$userId);
}

用于登录:

 /**
* 用于登录信息
*/
public function userLogin()
{
$redis = RedisInstance::MasterInstance();
$redis->select(10);
$username = 'tinywan8165';
$password = '123456';
$uid = $redis->get('user:username:'.$username.':userid');
if($uid == false){
exit('该用户名不存在');
}
$oldpwd = $redis->get('user:userId:'.$uid.':password');
if($password != $oldpwd){
exit('密码错误');
}
echo '登录成功,跳转';
homePrint($uid);
}

表名

global

列名

操作

备注

Global:userid

incr

产生全局的userid

Global:postid

Incr

产生全局的postid

Redis学习记录之————微博项目的更多相关文章

  1. redis 学习记录

    http://www.yiibai.com/redis/redis_quick_guide.html Redis 是一款依据BSD开源协议发行的高性能Key-Value存储系统(cache and s ...

  2. Redis学习记录(一)

    在学习Redis之前,要知道什么是NoSQL? 1.NoSQL 1.1. 什么是NoSQL NoSQL(NoSQL = Not Only SQL),表示“不仅仅是SQL”,泛指非关系型数据库. 1.2 ...

  3. Redis学习记录之Java中的初步使用

    1.关于Redis redis下载地址:<span style="font-family: Arial, Helvetica, sans-serif;">http:// ...

  4. Redis学习记录

    参考资料: http://www.dengshenyu.com/%E5%90%8E%E7%AB%AF%E6%8A%80%E6%9C%AF/2016/01/09/redis-reactor-patter ...

  5. Redis学习记录(三)

    1.Redis集群的搭建 1.1redis-cluster架构图 架构细节: (1)所有的redis节点批次互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽. (2)节点的fail ...

  6. Redis学习记录(二)

    1.Key命令 设置key的过期时间. expire key second:设置key的过期时间 ttl key:查看key的有效期(如果显示正数说明该key正在倒计时,如果是-1说明该key永久保存 ...

  7. Redis学习记录及Jedis代码示例

    文章目录 二.Redis简介 三.Redis安装 1. 下载并解压安装 2. 安装C语言编译环境 3. 修改安装位置 4. 编译安装 5.启动Redis服务器 ①默认启动 ②定制配置项启动 [1]准备 ...

  8. redis学习记录1 特性与优点

    1.存储结构:字符串.散列.列表.集合.有序集合. redis存储结构的优势:数据在redis中的储存方式和其在程序中的储存方式相近:redis对不同数据类型提供非常方便的操作方式,如使用集合类型储存 ...

  9. Redis——学习之路四(初识主从配置)

    首先我们配置一台master服务器,两台slave服务器.master服务器配置就是默认配置 端口为6379,添加就一个密码CeshiPassword,然后启动master服务器. 两台slave服务 ...

随机推荐

  1. [转]Using the Group Pane to Repeat Page Titles

    转自:http://www.wiseowl.co.uk/blog/s148/group-pane-advanced-mode.htm Repeating Page Headers in Reporti ...

  2. struts2结果类型

    struts2结果类型: 结果类型 描述 前request域属性是否丢失 1 dispatcher 用于与jsp整合的结果类型.默认结果类型. 2 chain Action链式处理结果类型.前一个Ac ...

  3. windows7 安装 memcached

    下载 memcached 的 windows 稳定 memcached.exe 版本,然后解压到某个目录下面,这里放到了 D:\ApacheServer\memcached 找到 C:\Windows ...

  4. 收集 关于php的博文

    1. 小狼的世界: 浅谈用php实现mvc:http://www.cnblogs.com/cocowool/archive/2009/09/08/1562874.html 关于MVC的定义和解释,可以 ...

  5. 原来样式改变不了(input type="file")

    label { background-color: #979fa8; color: #fff; display: inline-block; padding: .8rem 4rem; cursor: ...

  6. [lua]lua简介

    在这篇文章中,我想向大家介绍如何进行Lua程序设计.我假设大家都学过至少一门编程语言,比如Basic或C,特别是C.因为Lua的最大用途是在宿主程序中作为脚本使用的. Lua 的语法比较简单,学习起来 ...

  7. Spring MVC 的汉字乱码问题

    在web.xml文件加入 <filter> <filter-name>characterEncodingFilter</filter-name> <filte ...

  8. rtc关机闹钟6 AlarmManagerService研究

    这个是 private void setLocked(int type, long when) { if (mNativeData != 0) {            // The kernel n ...

  9. Accepted Necklace

    Accepted Necklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...

  10. 多校赛3- Solve this interesting problem 分类: 比赛 2015-07-29 21:01 8人阅读 评论(0) 收藏

    H - Solve this interesting problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I ...