-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first draft "@Cache*" annotations should only be applied on concrete …
…classes
- Loading branch information
1 parent
8483052
commit 6690481
Showing
1 changed file
with
24 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,45 @@ | ||
FIXME: add a description | ||
== Why is this an issue? | ||
|
||
// If you want to factorize the description uncomment the following line and create the file. | ||
//include::../description.adoc[] | ||
Annotating interfaces or interface methods with `@Cache*` annotations is not recommended. When using CGLIB-based proxies, these annotations will be ignored, and no caching proxy will be created. | ||
|
||
== Why is this an issue? | ||
=== What is the potential impact? | ||
|
||
FIXME: remove the unused optional headers (that are commented out) | ||
* *Confusing Code*: Developers may mistakenly believe that caching is in effect, leading to confusion and incorrect assumptions about application performance. | ||
|
||
//=== What is the potential impact? | ||
This rule raises an issue when an interface or an interface method is annotated with a `@Cache*` annotation. | ||
|
||
== How to fix it | ||
//== How to fix it in FRAMEWORK NAME | ||
|
||
Move `@Cache*` annotation from interface or interface method to the concrete class. | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,java,diff-id=1,diff-type=noncompliant] | ||
---- | ||
FIXME | ||
public interface ExampleService { | ||
@Cacheable("exampleCache") //non compliant, interface method is annotated with @Cacheable | ||
String getData(String id); | ||
} | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,java,diff-id=1,diff-type=compliant] | ||
---- | ||
FIXME | ||
@Service | ||
public class ExampleServiceImpl implements ExampleService { | ||
@Cacheable("exampleCache") | ||
@Override | ||
public String getData(String id) { | ||
// Implementation here | ||
} | ||
} | ||
---- | ||
|
||
//=== How does this work? | ||
|
||
//=== Pitfalls | ||
|
||
//=== Going the extra mile | ||
|
||
|
||
//== Resources | ||
//=== Documentation | ||
//=== Articles & blog posts | ||
//=== Conference presentations | ||
//=== Standards | ||
//=== External coding guidelines | ||
//=== Benchmarks | ||
== Resources | ||
=== Documentation | ||
* Spring - https://docs.spring.io/spring-framework/reference/integration/cache/annotations.html#cache-annotation-enable[Declarative Annotation-based Caching] |