* *Confusing Code*: Developers may mistakenly believe that caching is in effect, leading to confusion and incorrect assumptions about application performance.
This rule raises an issue when an interface or an interface method is annotated with a ``++@Cache*++`` annotation.
== How to fix it
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]
----
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]
----
@Service
public class ExampleServiceImpl implements ExampleService {
@Cacheable("exampleCache")
@Override
public String getData(String id) {
// Implementation here
}
}
----
== Resources
=== Documentation
* Spring - https://docs.spring.io/spring-framework/reference/integration/cache/annotations.html#cache-annotation-enable[Declarative Annotation-based Caching]