Skip to content

Instantly share code, notes, and snippets.

@cjnghn
Created September 5, 2023 04:06
Show Gist options
  • Save cjnghn/d1779ff01a864184b05b0123e41df8b8 to your computer and use it in GitHub Desktop.
Save cjnghn/d1779ff01a864184b05b0123e41df8b8 to your computer and use it in GitHub Desktop.
메모리 누수가 없는 모든 기능을 갖춘 메모리 저장소 모듈인 MemoryStore의 대안인 memorystore를 사용하는 예제
const session = require('express-session');
const MemoryStore = require('memorystore')(session);
app.use(session({
cookie: {
maxAge: 86400000 // 쿠키 만료 시간 설정
},
store: new MemoryStore({
checkPeriod: 86400000 // 24시간마다 만료된 항목 정리
}),
resave: false,
secret: 'your-secret-key'
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment