connect-redis - how to protect the session object against race condition
问题 I'm using nodejs with connect-redis to store the session data. I'm saving user data in the session, and use it for in the session lifetime. I've noticed that it's possible to have a race condition between two requests that changes the session data. I've tried to use redis-lock to lock the session, but it's a bit problematic for me. i don't want to lock the entire session, but instead lock only specific session variable. I found it to be impossible, and I thought about direction to solve it: