frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

redis cache and users out of sync [3:40pm] #78

Closed frankcollins3 closed 11 months ago

frankcollins3 commented 11 months ago

attempting to do: remember me user functionality.

error: web browser which returns ----> cache ? cache : prisma.users.findMany() "mastermizery" "justwater" "checkwater" "tonyhawk" "geturmanz" "shegotit"

psql (shell): mastermizery justwater checkwater supergood ilovecode tonyhawk geturmanz shegotit

redis-cli: ➜ ~ redis-cli 127.0.0.1:6379> GET users "[{\"id\":1,\"google_id\":\"no google-id\",\"icon\":\"/water_img/bottles.png\",\"username\":\"mastermizery\",\"email\":\"mastermizery@gmail.com\",\"password\":\"password\",\"age\":30},{\"id\":2,\"google_id\":\"no google-id\",\"icon\":\"/water_img/dolphin.png\",\"username\":\"justwater\",\"email\":\"justwater@gmail.com\",\"password\":\"waterpassword\",\"age\":27},{\"id\":3,\"google_id\":\"no google-id\",\"icon\":\"/water_img/target.png\",\"username\":\"checkwater\",\"email\":\"checkwater@gmail.com\",\"password\":\"checkpassword\",\"age\":25},{\"id\":4,\"google_id\":\"Google Account in Use. Profile can Fix.\",\"icon\":\"/water_img/bikini.png\",\"username\":\"tonyhawk\",\"email\":\"tonyhawk@gmail.com\",\"password\":\"$2a$13$j1Vx4R5kfw2hNDzFtTTH7uq6Zk6Mu/XuTSlzSoQYhZFXDm0PTh782\",\"age\":54},{\"id\":5,\"google_id\":\"no google-id\",\"icon\":\"/water_img/panda.png\",\"username\":\"geturmanz\",\"email\":\"geturmanz@gmail.com\",\"password\":\"Geturmanz3#\",\"age\":30},{\"id\":6,\"google_id\":\"no google-id\",\"icon\":\"/water_img/panda.png\",\"username\":\"shegotit\",\"email\":\"shegotit@gmail.com\",\"password\":\"$2a$13$cI8eQQ2cOdu1qmOJOzm6GO0nSbqynN7qcme7D40v2c3FWZIa4Gn6e\",\"age\":30}]" 127.0.0.1:6379>

proposed approach: signup process needs to include deleting and rewriting to cache

frankcollins3 commented 11 months ago

simple to do:

in the prisma .then() block => after creating the user during userSignup() and before returning said prisma-user data: let allusers = prisma.users.findMany() redis.del("users") let stringUser = await JSON.stringify(user) redis.set("users", stringUser

google-chrome-tools confirming all users that came from redis-cache from graphQL route not prisma: allUsernames (9) ['mastermizery', 'justwater', 'checkwater', 'supergood', 'ilovecode', 'tonyhawk', 'guyhanky', 'geturmanz', 'shegotit']