visionmedia/connect-redis — Issue #32: minimize redis commands when using RedisStore / connect-redis as SessionStore
Author: thomasfr
Created: 2011-10-25 12:58:34+00:00
State: open

When i am watching the commands in the redis-cli via the MONITOR command, i can see that there are at least 11 commands on a single requests.
I have RedisStore configured as described in the expressjs documentation. I am not storing any information in the session. I am not calling session.save() or redisStore.set or something.
The only thing i do is on a valid login i store the use object in the store, but the logs beneath came from the request to the login page.

1319547230.129921 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"
1319547230.135155 "setex" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs" "14400" "{\"lastAccess\":1319547230130,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-10-25T16:53:50.135Z\",\"httpOnly\":true,\"path\":\"/\"},\"error\":\"Access denied\"}"
1319547230.193424 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"
1319547230.194347 "setex" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs" "14400" "{\"lastAccess\":1319547230193,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-10-25T16:53:50.194Z\",\"httpOnly\":true,\"path\":\"/\"},\"error\":\"Access denied\"}"
1319547230.194826 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"
1319547230.195936 "setex" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs" "14400" "{\"lastAccess\":1319547230195,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-10-25T16:53:50.195Z\",\"httpOnly\":true,\"path\":\"/\"},\"error\":\"Access denied\"}"
1319547230.196972 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"
1319547230.197591 "setex" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs" "14400" "{\"lastAccess\":1319547230197,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-10-25T16:53:50.197Z\",\"httpOnly\":true,\"path\":\"/\"},\"error\":\"Access denied\"}"
1319547230.198899 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"
1319547230.199500 "setex" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs" "14400" "{\"lastAccess\":1319547230199,\"cookie\":{\"originalMaxAge\":14400000,\"expires\":\"2011-10-25T16:53:50.199Z\",\"httpOnly\":true,\"path\":\"/\"},\"error\":\"Access denied\"}"
1319547230.685981 "get" "sess:bhoT0peGyfFibks5uyilSWxU.fgnTjTqX3661xn5eRIwzEm4s1vQTTEJKX5mcTmBSROs"

It would be great to minimize the amount of commands to a very minimum. Maybe batching and caching some data, or maybe the SessionStore does some unnecessary commands anyway.
What do you think?