IDEA + JavaAI: A Hands‑On Review of Building a Mini‑Redis Spring Boot Starter

After struggling with AI‑generated code that failed on global edge cases, the author evaluates the FeiSuan JavaAI IDEA plugin, walking through its five‑agent workflow—from requirement planning to source generation—and demonstrates how it successfully creates a production‑ready mini‑redis Spring Boot starter with thorough testing.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
IDEA + JavaAI: A Hands‑On Review of Building a Mini‑Redis Spring Boot Starter

Practical Record

Preparation

Install the FeiSuan JavaAI plugin in IntelliJ IDEA via Settings → Plugins → Marketplace, searching for "CalEx JavaAI" or "飞算", then click Install and restart the IDE.

Requirement Description

The goal is to create a Java client for the open‑source mini‑redis project (a Go re‑implementation of Redis core commands). The client, named mini-redis-spring-boot-starter, must handle RESP protocol encoding/decoding, connection‑pool management, and full command coverage, plus optional slow‑query monitoring and persistence.

Accurately follow the RESP protocol when interacting with mini‑redis.

Fully support all commands and parameters of the current mini‑redis version.

Provide customizable slow‑query monitoring for complete read/write latency tracking.

Persist slow‑query information for stability observation over time.

Context Preparation and Prompt Input

The mini‑redis README, which lists all supported commands and their parameters, is imported as context for JavaAI. The full RESP specification is also included, allowing the AI to generate code that adheres to the protocol.

After selecting the "General" scenario, the author entered the core requirement and clicked the prompt‑optimization button. JavaAI produced the following detailed prompt:

开发一个名为 mini-redis-spring-boot-starter 的 Spring Boot 自动配置库。该库提供一个轻量级的 Redis 客户端实现,旨在替代或简化标准的 spring-data-redis 使用场景。核心功能包括:基于 TCP Socket 的原生 RESP 协议通信、高性能连接池管理、灵活的序列化策略(String/JDK/JSON)以及可选的 AOP 慢查询监控与带宽统计功能。

Design Phase

JavaAI’s design agent generated an architecture plan that selected Netty over the native JDK socket for better I/O performance, created a Spring Boot auto‑configuration module, and isolated RESP parsing into its own layer.

Technical choice: Netty instead of JDK Socket.

Auto‑configuration follows Spring Boot starter conventions.

Protocol handling is encapsulated in a separate module, keeping business logic decoupled.

The AI correctly limited exposed commands to those actually supported by mini‑redis (e.g., only lpush and rpop for list operations), demonstrating true context awareness.

Code Generation Plan

The source‑generation agent first produced a task breakdown before writing any code:

Initialize the project structure and parent‑child modules.

Implement the RESP engine with Netty (foundation for connection pooling and command execution).

Build a high‑performance connection pool using JDK Semaphore tied to the configured max connections, with a 5‑second timeout for acquisition.

Create a flexible serialization module exposing the API to developers.

The AI followed a bottom‑up construction order, starting with the protocol engine, then layering connection management, serialization, and finally business logic—mirroring a seasoned engineer’s approach.

Code Generation and Review

After confirming the plan, the source‑generation agent produced complete, runnable code. The core MiniRedisTemplate correctly encapsulated all commands. Two noteworthy details:

Redis expiration and condition parameters (EX/PX, NX/XX) are wrapped in a method named setIfAbsent, aligning with ConcurrentHashMap.putIfAbsent naming conventions.

Both synchronous and asynchronous variants are provided for each command, with the synchronous methods delegating to the asynchronous implementation to avoid duplication, similar to enterprise frameworks like Redisson.

The connection‑pool method getConnection uses a Semaphore whose permits match the max pool size, reuses idle connections, creates new ones only when necessary, and applies a 5‑second timeout to prevent long blocking.

For RESP encoding, the AI generated a ChannelOutboundHandlerAdapter that follows the protocol rules precisely, using * for array length and $ for bulk string length, then appending \r\n. An example with the scan 0 command shows the correct binary representation.

*2
# Output array length 2
$1
0
*2
$6
user:1
$6
user:2

Fine‑Tuning

After reviewing the generated connection‑pool code, the author prompted the AI to make the getConnection logic more flexible. The AI responded with a high‑compliance adjustment that preserved reusability while allowing finer‑grained control.

Unit Test Verification

Using an AI‑driven unit‑test generator, the author produced comprehensive test cases covering normal, boundary, and error scenarios for each command. The generated tests injected MiniRedisTemplate and verified that set and get operations round‑trip correctly.

The test run confirmed that the written and read strings matched exactly, validating the command encapsulation and transmission logic.

Conclusion

The end‑to‑end collaboration with FeiSuan JavaAI demonstrates that its multi‑agent workflow—requirement planning, interface design, database schema, business logic, and source generation—produces engineering‑grade code with minimal manual intervention. While human review remains essential, the tool markedly reduces the effort required to deliver a functional, production‑ready component.

Overall, the AI‑generated code is not a raw snippet but a cohesive, test‑validated library that respects protocol specifications and architectural best practices.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaAI Code GenerationRedisNettyAgentSpring BootIDEA
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.