eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – LJB – NPI EA (cat = Core Java)
announcement - icon

Code your way through and build up a solid, practical foundation of Java:

>> Learn Java Basics

1. Overview

Often, we find it challenging to decide on a non-relational database as a primary data store for our applications.

In this article, we’ll explore two popular non-relational databases, Redis and MongoDB.

First, we’ll take a quick look at the features offered by Redis and MongoDB. Then, we’ll discuss when to use Redis or MongoDB by comparing them against each other.

2. Redis

Redis is an in-memory data structure store that offers a rich set of features. It’s useful as a cache, message broker, and queue.

2.1. Features

2.2. Installation

We can download the latest Redis server from the official website and install it:

$ wget http://download.redis.io/releases/redis-6.0.9.tar.gz
$ tar xzf redis-6.0.9.tar.gz
$ cd redis-6.0.9
$ make

3. MongoDB

MongoDB is a NoSQL document database that stores information in a JSON-like document structure. It’s useful as a schemaless data store for rapidly changing applications, prototyping, and startups in a design and implementation phase.

3.1. Features

  • Offers an interactive command-line interface MongoDB Shell (mongosh) to perform administrative operations and query/update data
  • JSON based query structure with the support of joins
  • Supports various types of searches like geo-based search, graph search, and text search
  • Supports multi-document ACID transactions
  • Spring Data support
  • Available in community, enterprise, and cloud (MongoDB Atlas) editions
  • Various drivers for major technologies like C++, Java, Go, Python, Rust, and Scala
  • Provides GUI to explore and manipulate data through MongoDB Compass
  • Offers a visual representation of data using MongoDB Charts
  • MongoDB BI Connector provides connections to BI and analytics platforms

3.2. Installation

We can download the latest MongoDB server or, if using macOS, we can install the community edition directly using Homebrew:

brew tap mongodb/brew
brew install [email protected]

4. When to Use Redis?

4.1. Caching

Redis provides best-in-class caching performance by providing sub-millisecond response time on frequently requested items.

Furthermore, it allows setting expiration time on keys using commands like EXPIRE, EXPIREAT, and PEXPIRE.

At the same time, we can use the PERSIST command to remove the timeout and persist the key-value pair, making it ideal for caching.

4.2. Flexible Data Storage

Redis provides various data structures like string, list, set, and hash to decide how to store and organize our data. Hence, Redis gives us full freedom over the implementation of the database structures.

However, it may also require a long time to think through the DB design. Similarly, it can be challenging to build and maintain the inner structure of the schema using Redis.

4.3. Complex Data Storage

Similarly, with the combination of the list, set, and hash, we can implement complex data structures like queues, arrays, sorted sets, and graphs for our storage.

4.4. Chat, Queue, and Message Broker

Redis can publish and subscribe to messages using pub/sub message queues with pattern matching. Thus, Redis can support real-time chat and social-media feed applications.

Similarly, we can implement a lightweight queue using the list data structure. Furthermore, Redis’s list supports atomic operations and offer blocking capabilities, making it suitable to implement a message broker.

4.5. Session Store

Redis provides an in-memory data store with persistence capabilities, making it a good candidate to store and manage sessions for web/mobile applications.

4.6. IoT and Embedded Systems

As per Redis’s official documentation, newer versions starting from 4 and 5 support the ARM processor and the Raspberry Pi.

Also, it runs on Andriod, and efforts are in place to include Android as an officially supported platform.

So, Redis looks ideal for IoT and embedded systems, benefitted by its small memory footprint and low CPU requirements.

4.7. Real-Time Processing

Being a blazing fast in-memory data structure, we can use it for real-time processing applications.

For instance, Redis can efficiently serve applications that offer features like stock price alerts, leaderboards, and real-time analytics.

4.8. Geospatial Apps

Redis offers a purpose-built in-memory data structure Geo Set – built on sorted set – for managing geospatial indices. Also, it provides specific geo commands like GEOADD, GEOPOS, and GEORADIUS to add, read, and analyze geospatial data.

Therefore, we can build real-time geospatial applications with location-based features like drive time and drive distance using Redis.

5. When to Use MongoDB?

5.1. Dynamic Queries

MongoDB offers a powerful set of query tools. Also, it provides a wide range of flexible query schemes like geo-based search, graph search, and text search for efficient data retrieval.

At the same time, with the support of JSON-structured queries, MongoDB looks to be a better choice for scenarios where data search and analytics are daily activities.

5.2. Rapidly Changing Schema

MongoDB can be helpful in the design and early implementation phases, where we require quick changes to our schema. At the same time, it doesn’t make assumptions on the underlying data, and it optimizes itself without needing a schema.

5.3. Prototyping and Hackathons

By following the JSON-like document structure, MongoDB allows for rapid prototyping, quick integrations with front-end channels, and hackathons.

At the same time, it can be useful for junior teams that don’t want to deal with the complexities of an RDBMS.

5.4. Catalogs

By providing a dynamic schema that is self-describing, MongoDB makes it easier to add products, features, and recommendations for catalogs like e-commerce, asset management, and inventory.

We can also use expressive queries in MongoDB for features like advanced search and analytics by indexing a field or set of fields of the JSON-structured document.

5.5. Mobile Apps

MongoDB’s JSON document structure allows storing different types of data from various devices along with geospatial indexes.

Besides, horizontal scalability with native sharding allows easy scaling of a mobile app. Therefore, MongoDB can serve tons of users, process petabytes of data, and support hundreds of thousands of operations per second, making it a worthy choice for backing mobile apps.

5.6. Content-Rich Apps

It’s not easy to incorporate various content in RDBMS for modern content-rich apps. On the other hand, MongoDB allows storing and serving rich content like text, audio, and video.

Also, we can easily store files larger than 16MB efficiently using MongoDB GridFS. It allows accessing a portion of large files without loading the entire file into memory.

Additionally, it automatically syncs our files and metadata across all servers. As a result, MongoDB looks to be a more suitable choice for supporting content-rich apps.

5.7. Gaming Apps

Similar to mobile and content-rich apps, gaming also requires massive scaling and dynamic data structures. Thus, MongoDB can be a promising choice for gaming apps.

5.8. Global Cloud Database Service

MongoDB Atlas is available across multiple cloud services like AWS, Google Cloud, and Azure. In addition, with built-in replication and failover mechanism, it offers a highly available distributed system. Therefore, we can quickly deploy and manage the database and use it as a global cloud database service.

6. Conclusion

In this article, we explored Redis and MongoDB as choices for a non-relational database.

First, we looked at the features offered by both databases. Then, we explored scenarios where one of them is better than the other.

We can certainly conclude Redis looks promising as a better solution for caching, message broker, and queue. At the same time, it can prove worthy in real-time processing, geospatial apps, and embedded systems.

On the other hand, MongoDB is a solid choice for storing JSON-like objects. As a result, MongoDB can be best suited for schema-less architecture for prototyping, modern-day content-rich, mobile, and gaming applications.

Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

eBook Jackson – NPI EA – 3 (cat = Jackson)