<> demand

There is an interesting demand recently , Establishment of user's family account system , premise ( Small program development , Front end can't detect applet exit completely ), Member accounts in the family A Before switching login, you need to judge another account B Last use time of No , If the account number A stay
Logged in within two hours , I will check the account number A There's a hint , Do you want to squeeze out accounts B, Simultaneous account number B When calling the request again , You'll also receive the account number you've been given A Crowd out the notice , Exit to the authorization login interface .

<> terms of settlement

Because of the above requirements, the solution is to use Redis,Redis Set a valid time for each account in (2 hour ) Of token value , By judging each user token Does the value exist , To judge all kinds of reminders when the account is squeezed out . But there's a problem , Requirements token What is the failure time 2 hour , Last account within two hours
Login will remind ( The last update of the previous account needs to be judged token time ), So the front end calls each request , The back end needs to be updated redis Expiration time of .

* Node.js Quoted in Redis var redis = require('redis'), PORT = 6389,// Port number HOST =
'', // The server IP PWD = '88888888888888', // password OPTS = {},// Set item rclient =
rclient.auth(RDS_PWD,function(){ console.log('redis Certified '); }); //redis database
rclient.set('token','kaola');// assignment
* Redis set up key Expiration time of rclient.expire('token',60);// set up 60 Seconds automatically expired
Redis to update key Expiration time of

For a person who already has time to live key implement EXPIRE command , The new specified lifetime will replace the old lifetime
rclient.expire('token',60);// to update token Expiration time 60 second
attach : The small requirements mentioned above are the way to think of at present , If there is a better way to realize it, we can discuss it together .

©2020 ioDraw All rights reserved
Swing actual combat Understanding closure about vue in el-date-picker type=daterange The problem of date not echoing Ubuntu 18.04 swap Partition expansion Snake code --c Language Edition visual c++6.0 open 【Golang Basic series 10 】Go language On conditional sentences ifString class —— summary ,String The nature of , Memory resolution , Commonly used APIAdobe Illustrator Publish native support Apple Silicon Test version of the software study java My first class antd table sort