refactor: setex
This commit is contained in:
parent
b270223f4b
commit
1b18e86a8b
|
@ -64,24 +64,22 @@ export default (latus) => class MessageServer extends Message(latus) {
|
|||
uuid,
|
||||
}])
|
||||
));
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise((r, e) => {
|
||||
const rendered = renderChannel(channel);
|
||||
const serverChannel = 'r' === type
|
||||
? rendered
|
||||
: `/u/${[name, req.user.redditUsername].sort().join('$')}`;
|
||||
const key = `${serverChannel}:messages:${uuid}`;
|
||||
const ttl = channelIsAnonymous(channel) ? 60 : 600;
|
||||
pubClient
|
||||
.multi()
|
||||
.set(key, JSON.stringify({
|
||||
.setex(key, ttl, JSON.stringify({
|
||||
distinction,
|
||||
ip: req.ip,
|
||||
message,
|
||||
owner,
|
||||
socket: socket.id,
|
||||
timestamp,
|
||||
}))
|
||||
.expire(key, channelIsAnonymous(channel) ? 60 : 600)
|
||||
.exec((error) => (error ? reject(error) : resolve([timestamp, uuid])));
|
||||
}), (error) => (error ? e(error) : r([timestamp, uuid])));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user