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. 时间戳转换成Date

    SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); String date = for ...

  2. C#中的属性————只谈属性

    废话少说直接一剑封喉--属性是对私有字段的保护(其实是对私有字段引用的另外一种变相公开化),属性在没有任何操作的时候是无法看出其优势来,上例子 // Field used by property.pr ...

  3. greenplum集群安装

    一.环境配置 1.地址分配 192.168.1.201 mdw master 192.168.1.202 sdw1 segment1 192.168.1.203 sdw2 segment2 2.创建用 ...

  4. 发现一个jq的问题

    用jq对checkbox的checked属性进行操作时,使用$(‘#id’).attr(‘checked’, true);竟然无效,改成$(‘#id’).prop(‘checked’, true);才 ...

  5. poj1961 Period

    我们考虑KMP算法中fail失配指针的意义. 对于一个模式串(Pattern),位置i对应的失配指针fail[i]是那个位置: 这个位置满足的条件是,子串[0, fail[i])是位置i(不含)的后缀 ...

  6. httpclient4.3.6/httpcore-4.4自己封装的工具类

    引入jar包 httpclient4.3.6/httpcore-4.4 package com.develop.util; import java.io.IOException; import jav ...

  7. java解析密钥格式

    import java.io.StringReader; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1 ...

  8. HDU 5615 Jam's math problem

    Jam's math problem Problem Description Jam has a math problem. He just learned factorization.He is t ...

  9. SqlSever基础 convert 将类型为字符的一列转成Int类型后进行排序

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  10. CodeForces 454C Little Pony and Expected Maximum

    Little Pony and Expected Maximum Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I6 ...