Spring Boot Cache with AES Parameter Encryption
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md to install @user_faca7523/springboot-cache-aes.
About this skill
Problem to solve
Spring Boot service methods often repeat database queries, but hand-written caching quickly runs into inconsistent key rules, sensitive parameters exposed in plaintext, and uneven Redis serialization. This skill targets those issues by providing an AOP plus Redis cache annotation pattern with AES parameter protection, suitable as a starting point for internal service caching.
How it works
- Use the
CacheDataAnnotationannotation on a method, and letCacheDataAnnotationAopread or write the cache before and after method execution. - Supports three key generation strategies: fixed key, SpEL expression, and class method name with AES parameter digest, in descending priority, so you can switch between stable keys and dynamic parameters.
- Method parameters are AES-encrypted before being used in keys or protected from plain exposure, reducing the risk of sensitive values entering cache keys directly.
- The setup includes Maven dependencies, Redis configuration,
RedisConfigserializers, and annotation code; copy the files into the project and adjust package names. - Null results are not cached by default, avoiding treating
nullas valid business data; caching nulls requires custom AOP changes.
Boundaries and cautions
- Cached objects must be serializable; prefer
String, primitive wrappers,List, andMapwith serializable elements. - SpEL depends on parameter names, so compile with
-parameters; methods must bepublic, non-static, and called through the Spring container, because self-invocation bypasses AOP. - In production, configure Redis connection pooling, reasonable TTLs, key prefixes, and hotspot warm-up or invalidation policies.
- For queries that may return
null, combine null caching, parameter validation, or Bloom filters to reduce cache penetration.
Use Cases
- Add caching to Spring Boot query endpoints and generate dynamic keys from user IDs using SpEL.
- Encrypt method parameters with AES before they enter cache keys to avoid exposing sensitive values.
- Manage Redis cache reads and writes with an AOP annotation while handling serializable returns and null results.
- Verify SpEL parameter names, public non-static methods, and Spring container calls before enabling AOP caching.
Best For
- Java engineers maintaining Spring Boot endpoints who need Redis caching and controlled cache-key rules.
- Backend engineers focused on service security who want sensitive method parameters kept out of plain cache keys.
- Platform engineers using Redis for business caching who need consistent AOP annotations, serializers, and null handling.
- Tech leads reviewing legacy cache modules who want to check SpEL usage, AOP self-invocation, and serialization issues.
Related Skills
Automatically indexes Gradle-cached AAR/JAR dependency classes and returns library coordinates, versions, and public APIs by fully qualified name, using only the Python standard library.
Codifies AMT and YourMT3 training conventions, script patterns, hyperparameters, precision, checkpoints, and NaN safeguards.
Retrieve relevant chunks from a customer-managed PKM dataset by dataset_id and return concise, source-annotated answers.
Convert PRDs, user stories, or functional specs into prioritized test-point checklists covering functional, business-rule, boundary, exception, and non-functional dimensions.