I would like to set the ttl for a collection once, what is the idiomatic way of achieving this when building a java application that uses mongoDB? Do ppl simply apply settings like these in the shell? Or in the application code is it normal to check if a collection is already in the DB, if it is not then create it with the desired options?

Thanks!

解决方案

I never do index building in my application code anymore.

I confess that I used to. Everytime my application started up I would ensure all my indexes, until suddenly one day a beginner developer got hold of my code and accidently deleted a character within one of my index sequences.

Consequently the entire cluster froze and went down due to processing, in the foreground, this index building. Fortunately I had a number of delayed and non-index building slaves to repair from but still, I lost about 12 hours all in all and in turn 12 hours of business.

I would recommend you don't do your index building in the application code but instead carfully within your mongo console. That goes for any operation like this, even TTL indexing.

mongodb ttl java,在mongoDB集合上设置ttl-是在应用程序中还是在shell中?相关推荐

  1. 如何在watchOS 7中的Apple Watch上设置和使用睡眠应用程序?

    在watchOS 7发行版中将Apple Watch的睡眠跟踪功能包括在内,这意味着您可以随身携带最好的Apple Watch.Apple Watch上的新睡眠应用程序不仅仅是跟踪睡眠,它旨在帮助您建 ...

  2. mongodb数据库java接口,MongoDB —— 使用Spring Data MongoDB操作数据库

    我们使用Spring Data MongoDB可以方便的在Spring boot项目中操作MongoDB 文档地址:https://docs.spring.io/spring-boot/docs/2. ...

  3. Ubuntu 16.04 火狐添加java插件、解决Firefox强制低版本java插件运行以及安全设置限制自签名应用程序运行

    1.火狐添加java 插件 我的jdk是1.7版本在/home/lzhprogram/java目录 火狐插件文件夹在/usr/user/mozija/plugins 使用如下软链接即可给火狐添加插件 ...

  4. linux上设置svn账户权限设置密码,Linux:如何在svn中设置“全局”用户/密码/组文件...

    好的,我找到了一种更好的方法来建立全局认证/访问.如果该信息可以帮助- 要删除或创建新用户,我使用了一个全局"passwd"文件(没有组!)/ home / svn / passw ...

  5. java 只显示文本文件_Java设计并实现一个应用程序,能够读取一个文本文件中的内容并显示,同时能够计算出文本中的行数。...

    展开全部 java编写显示文本的应用程序, 需要用到图形界面GUI编程技术. 步骤一: 需要搭建一个整体的外观32313133353236313431303231363533e4b893e5b19e3 ...

  6. java socket 设置 ttl_嵌入式 socket编程设置TTL

    #include #include int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); in ...

  7. 【基础】Java 并发编程(上)

    Java 并发编程(上) JUC 概述 什么是 JUC? 线程与进程 并发与并行 线程基础概述 线程的状态 线程的活性故障 死锁的必要条件 避免死锁的方法 线程锁死的分类 公平调度与非公平调度 多线程 ...

  8. html 移动设备不显示,IT兄弟连 HTML5教程 在移动设备上设置原始大小显示

    原标题:IT兄弟连 HTML5教程 在移动设备上设置原始大小显示 在iPhone系列和iPod Touch中使用的是Safari浏览器,它支持前面介绍的媒体查询表达式.例如,使用iPhone 320p ...

  9. java面试题:集合_Java:选择正确的集合

    java面试题:集合 这是在您的应用程序中选择Set , List或Map的正确实现的快速指南. 最好的通用或"主要"实现可能是ArrayList,LinkedHashMap和Li ...

最新文章

  1. C++中关键字的理解--Static
  2. SpringBoot-切面AOP实现统一逻辑处理
  3. 细胞冻存及细胞计数的技巧
  4. asp.net core web mvc之异常
  5. plsql developer 安装在win7 64位电脑路径问题
  6. 【STM32】修改芯片型号后报 Error 的解决方案
  7. 注解@RequestParam【不添加默认项注解】与@RequestBody的使用场景
  8. day3—python——字符串常用方法
  9. mysql raiserror_SQL Server自定义异常的使用raiserror
  10. swagger生成错误问题 汇总解决
  11. 关于用C#编写ActiveX控件3(转)
  12. [USB-Blaster] Error (209040): Can't access JTAG chain
  13. Java多线程实现-线程池
  14. Lync Server在父子域环境中使用图形界面扩展AD架构失败
  15. 智能运维发展史及核心技术研究
  16. 机器学习——随机森林算法及原理
  17. 中文拼音表,完全包括GB2312字库中的字(除极少数生僻字)
  18. Android 中获取符合分辨率的视频
  19. 《高情商修炼手册》 by 小粥超人(小hi)Hygge @Chou
  20. 个人书籍收藏及问题研究(!!! , 读书计划)

热门文章

  1. arduino扩展板的使用_如何使用Arduino和React为烧烤构建仪表板
  2. 2010年高教社杯全国大学生数学建模竞赛题目B题解析及层次分析法AHP在其中的应用
  3. sql 注入防护与xss攻击防护
  4. 贝叶斯分类器用于文本分类: Multinomial Naïve Bayes
  5. 死锁(python 版)
  6. python是动态语言
  7. ASP.NET 操作Cookie详解 增加,修改,删除
  8. 有功功率 无功功率 功率因数
  9. Security Tutorials系列文章第七章:User-Based Authorization(下)
  10. 有什么软件可以测试手机gprs,哪个软件可通过GPRS发信息啊?