Skip to Content
몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지
book

몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지

by 김인범, 크리스티나 초도로우, 섀넌 브래드쇼, 오언 브라질
March 2021
Beginner to intermediate
600 pages
12h 19m
Korean
Hanbit Media, Inc.
Content preview from 몽고DB 완벽 가이드(3판): 실전 예제로 배우는 NoSQL 데이터베이스 기초부터 활용까지
216
2
몽고DB 개발
6.4
TTL
인덱스
6
.
3
절에서 설명했듯 제한 컬렉션 내용이 덮어쓰일 때는 제어할 수 없다. 오래된 순 삭제 시스
템을 더 유연하게 만들려면
TTL
인덱스를 이용해서 각 도큐먼트에 유효 시간을 설정할 수 있
다. 도큐먼트는 미리 설정한 시간에 도달하면 지워진다. 이런 인덱스는 세션 스토리지와 같은
문제를 캐싱하는 데 유용하다.
createIndex
의 두 번째 인자에
"
expireAfterSeconds
"
옵션을 명시해
TTL
인덱스를 생성
한다.
> // 24시간 뒤 타임아웃
> db.sessions.createIndex({"lastUpdated" : 1}, {"expireAfterSeconds" : 60*60*24})
명령은
"
lastUpdated
"
필드에
TTL
인덱스를 생성한다. 도큐먼트에
"
lastUpdated
"
필드가
존재하고 날짜형이라면, 서버 시간이 도큐먼트 시간의
"
expireAfterSeconds
"
초를 지나면
도큐먼트가 삭제된다.
활동 중인 세션이 삭제되는 것을 방지하려면 활동
activity
이 있을 때마다
"
lastUpdate
"
필드를
현재 시간으로 갱신한다.
"
lastUpdated
"
24
시간이 지나면 도큐먼트는 삭제된다.
몽고
DB
TTL
인덱스를 매분마다 청소하므로 초 단위로 신경 쓸 필요 없다.
collMod ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

풀스택 서버리스: 리액트, AWS, 그래프QL을 이용한 최신 애플리케이션 개발

풀스택 서버리스: 리액트, AWS, 그래프QL을 이용한 최신 애플리케이션 개발

김범준, 네이더 다빗

Publisher Resources

ISBN: 9791162244067