Caching Mongoose queries in a native MongoDB collectionArticle contains
  1. The problem with traditional caching
  2. A aifferent approach with MongoDB as cache storage
    1. Why MongoDB?
  3. Key features
    1. 1. Query caching
    2. 2. Automatic invalidation
    3. 3. Cross-collection invalidation
    4. 4. Size limit and periodic sweep
    5. 5. Connection-pool resilience
    6. 6. Multi-database support
  4. How it works: architecture
    1. Scalability benefits
  5. Quick start
  6. Comparison: Redis vs. MongoDB-native caching
  7. When to use this package
  8. Best practices
    1. 1. Start with high-impact queries
    2. 2. Set appropriate TTLs
    3. 3. Monitor cache size
    4. 4. Understand the coarse-grained invalidation
    5. 5. Test cache behavior under load
  9. Comparison with other solutions
  10. Final thoughts
Set of computers showing infrastructure for databases. Image by Suresh anchan from Pixabay.

Caching Mongoose queries in a native MongoDB collection

If you’re building a Node.js application with Mongoose, you’ve probably felt the pain of database performance at scale. The go-to solution? Add Redis. Set up a caching layer, wire it into your queries, and hope the invalidation logic doesn’t become a maintenance nightmare.

But what if we told you there’s a simpler way – one that uses the database you already have, requires zero additional infrastructure, and handles cache invalidation automatically?

Meet @sitelintpackages/mongoose-cache: a MongoDB-based caching solution for Mongoose queries with TTL and automatic invalidation support.

Continue reading “Caching Mongoose queries in a native MongoDB collection”
Flush (Delete or Empty) MongoDB log fileArticle contains
  1. Locating your MongoDB logs
  2. Clearing the current MongoDB logs
  3. Deleting the old MongoDB logs
  4. Determining the size of the MongoDB log directory
  5. Rotating MongoDB log files: a comprehensive guide
    1. Starting the rotation process: tips and tricks
Hundreds of drawers symbolizing a large amount of occupied space

Flush (Delete or Empty) MongoDB log file

Sometimes the database might work slowly and one of the reasons is a large log file. Tracking database activity is crucial for performance and issues monitoring. However, the log file may grow and therefore may cause the performance issue because of more and more writing and reading on a larger and larger log file. We may avoid such problems by scheduling regular log rotation and keeping the log file size below a defined threshold. Let’s get started on figuring out how to address this issue.

Continue reading “Flush (Delete or Empty) MongoDB log file”