userService.js 583 B

123456789101112131415161718192021
  1. import { pubClient } from "../connection/redis.js";
  2. const updateUser = async (userId, userObj) => {
  3. // const user = await pubClient.exists(userId);
  4. // if (user === 1) {
  5. // await pubClient.hSet(userId, userObj);
  6. // }
  7. await pubClient.hSet(userId, userObj.from, JSON.stringify(userObj));
  8. await pubClient.expire(userId, 60 * 60 * 24);
  9. };
  10. const removeRoomAllUsers = (roomId) => {
  11. return pubClient.del(roomId);
  12. };
  13. const removeRoomUser = (roomId, useId) => {
  14. return pubClient.hDel(roomId, useId);
  15. };
  16. export { updateUser, removeRoomAllUsers, removeRoomUser };