基於Redis的微博的註冊

2021-10-07 14:33:25 字數 1423 閱讀 7905

# 基於redis的微博的註冊

redis在網際網路公司中是必選的技術,因為網際網路公司的系統天生就是高併發特徵。但是能把redis運用的最好的就屬微博了。

正因為redis的廣泛應用,使得微博能夠快速支撐日活躍使用者超2億,每日訪問量百億級,歷史資料高達千億級。

微博線上規模,100t+ 儲存,1000+ 臺物理機,10000+redis 例項

正因為redis在微博廣泛使用,所有我們針對微博應用場景來學習redis,我們分為5個階段來學習。

### 一、註冊微博的redis技術方案

### 二、springboot+redis 實現微博註冊

#### 步驟1:建立user表

```

drop table if exists `users`;

create table `users` (

`id` int(10) unsigned not null auto_increment,

`username` varchar(50) not null default '' comment '使用者名稱',

`password` varchar(50) not null default '' comment '密碼',

`***` tinyint(4) not null default '0' comment '性別 0=女 1=男 ',

`deleted` tinyint(4) unsigned not null default '0' comment '刪除標誌,預設0不刪除,1刪除',

`update_time` timestamp not null default current_timestamp on update current_timestamp comment '更新時間',

`create_time` timestamp not null default current_timestamp comment '建立時間',

primary key (`id`)

) engine=innodb auto_increment=1 default charset=utf8 comment='使用者表';

set foreign_key_checks = 1;

```#### 步驟2:註冊邏輯

```

@api(description = "使用者介面")

@restcontroller

public class usercontroller

} /**

* 微博註冊

*/public void createuser(user obj)

```### 三、體驗

基於Redis的使用者發微博

步驟1 建立content表create table content id int 10 unsigned not null auto increment,user id int 10 not null default 0 comment 使用者id content varchar 5000 not...

基於redis的微博個人首頁

使用者發的文章是hash儲存,key為postid 使用者的關注的人set儲存,fowlee 使用者的被關注的人set儲存,follower 我的主頁是乙個list,userid 後面是postid 關注的頁面是乙個list,userid後面是關注人之前發過的postid 使用者發了文章,首先將文章...

02 微博賬號註冊

進入首頁。建立 接入的應用 外鏈轉存失敗,源站可能有防盜煉機制,建議將儲存下來直接上傳 img uqocmcmd 1602230072860 c users lucky pictures camera roll 微博賬號註冊1.png 外鏈轉存失敗,源站可能有防盜煉機制,建議將儲存下來直接上傳 im...