Chapter 3: Managing Data Persistence with MongoDB

In the previous chapter, we learned how to build a RESTful API with the Gin web framework. In this one, we will integrate MongoDB into the backend for data storage, and we will also cover how to optimize database queries with Redis as a caching layer.

In this chapter, we will cover the following topics:

  • Setting up MongoDB with Docker
  • Configuring Go MongoDB driver
  • Implementing MongoDB queries & and CRUD operations
  • Standard Go project layout
  • Deploying Redis with Docker
  • Optimizing API response time with caching
  • Performance benchmark with Apache Benchmark

By the end of this chapter, you will be able to perform CRUD operations on a MongoDB database using Go.

Technical requirements

To follow the ...

Get Building Distributed Applications in Gin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.