Redis学习记录之————微博项目
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学习记录之————微博项目的更多相关文章
- redis 学习记录
http://www.yiibai.com/redis/redis_quick_guide.html Redis 是一款依据BSD开源协议发行的高性能Key-Value存储系统(cache and s ...
- Redis学习记录(一)
在学习Redis之前,要知道什么是NoSQL? 1.NoSQL 1.1. 什么是NoSQL NoSQL(NoSQL = Not Only SQL),表示“不仅仅是SQL”,泛指非关系型数据库. 1.2 ...
- Redis学习记录之Java中的初步使用
1.关于Redis redis下载地址:<span style="font-family: Arial, Helvetica, sans-serif;">http:// ...
- Redis学习记录
参考资料: http://www.dengshenyu.com/%E5%90%8E%E7%AB%AF%E6%8A%80%E6%9C%AF/2016/01/09/redis-reactor-patter ...
- Redis学习记录(三)
1.Redis集群的搭建 1.1redis-cluster架构图 架构细节: (1)所有的redis节点批次互联(PING-PONG机制),内部使用二进制协议优化传输速度和带宽. (2)节点的fail ...
- Redis学习记录(二)
1.Key命令 设置key的过期时间. expire key second:设置key的过期时间 ttl key:查看key的有效期(如果显示正数说明该key正在倒计时,如果是-1说明该key永久保存 ...
- Redis学习记录及Jedis代码示例
文章目录 二.Redis简介 三.Redis安装 1. 下载并解压安装 2. 安装C语言编译环境 3. 修改安装位置 4. 编译安装 5.启动Redis服务器 ①默认启动 ②定制配置项启动 [1]准备 ...
- redis学习记录1 特性与优点
1.存储结构:字符串.散列.列表.集合.有序集合. redis存储结构的优势:数据在redis中的储存方式和其在程序中的储存方式相近:redis对不同数据类型提供非常方便的操作方式,如使用集合类型储存 ...
- Redis——学习之路四(初识主从配置)
首先我们配置一台master服务器,两台slave服务器.master服务器配置就是默认配置 端口为6379,添加就一个密码CeshiPassword,然后启动master服务器. 两台slave服务 ...
随机推荐
- xib托线出来的为什么是weak而不是strong
因为控件他爹( view.superview )已经揪着它的小辫了( strong reference ),你( viewController )眼瞅着( weak reference )就好了. 当 ...
- 【转】Windows下搭建cvs服务器
转载地址:http://hi.baidu.com/iloverobot/item/fad1eb6d66c45e166995e66d 下载cvs server:CVSNT 网址为:http://www. ...
- [团队项目]第二个冲刺 看板和燃尽图 Sprint2 6.8/6.9/6.10/6.11/6.12/6.13/6.14
1.开始一个新的冲刺: 起止:2016.6.1~2016.6.14 按照以下过程进行 ProductBacklog:继续向下细化 Sprint 计划会议:确定此次冲刺要完成的目标 Sprint Bac ...
- stl map底层之红黑树插入步骤详解与代码实现
转载注明出处:http://blog.csdn.net/mxway/article/details/29216199 本篇文章并没有详细的讲解红黑树各方面的知识,只是以图形的方式对红黑树插入节点需要进 ...
- HDU 4715:Difference Between Primes
Difference Between Primes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- C#中进行单元测试
首先创建一个项目,写一段待测的程序: namespace ForTest { public class Program { static void Main(string[] args) { } pu ...
- ExecutorService - 10个技巧和窍门
ExecutorService已经成为Java并发编程中常用的基础库,几乎所有到线程 任务等执行都要委托ExecutorService.下面是使用过程中10个技巧和窍门. 1.为线程池和线程取名 当我 ...
- 2016 ACM/ICPC Asia Regional Qingdao Online HDU5883
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5883 解法:先判断是不是欧拉路,然后枚举 #pragma comment(linker, "/S ...
- Codeforces Round #368 (Div. 2) C
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...
- Android属性动画完全解析(上)
Android属性动画完全解析(上) 转载:http://blog.csdn.net/guolin_blog/article/details/43536355 在手机上去实现一些动画效果算是件比较炫酷 ...