Spring: @Cacheable does not cache what you think when the key collides

The default key is built from all method parameters. Two methods on the same cache name with different parameter shapes can generate equal keys, and one method starts returning the other's values - a silent, correct-looking data leak.

Full code & output

This topic is available to PRO members.

Sign in Create a free account

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25