|
21 | 21 | import java.lang.annotation.Target;
|
22 | 22 |
|
23 | 23 | /**
|
24 |
| - * Annotation for enabling local caching on method results to enhance performance |
25 |
| - * by reducing redundant computations and minimizing repeated data retrievals from |
26 |
| - * external sources such as databases or APIs. |
| 24 | + * Annotation for enabling local caching on method results to enhance |
| 25 | + * performance by reducing redundant computations and minimizing repeated data |
| 26 | + * retrievals from external sources such as databases or APIs. |
27 | 27 | *
|
28 | 28 | * <p>
|
29 |
| - * This annotation provides a flexible caching mechanism with configurable properties: |
| 29 | + * This annotation provides a flexible caching mechanism with configurable |
| 30 | + * properties: |
30 | 31 | * <ul>
|
31 |
| - * <li><strong>durationInMinute</strong>: Defines the lifespan of cached entries in minutes.</li> |
32 |
| - * <li><strong>maxRecord</strong>: Specifies the maximum number of entries that can be stored in the cache.</li> |
33 |
| - * <li><strong>autoCache</strong>: Determines whether caching should be automatically applied when the method is invoked.</li> |
| 32 | + * <li><strong>durationInMinute</strong>: Defines the lifespan of cached entries |
| 33 | + * in minutes.</li> |
| 34 | + * <li><strong>maxRecord</strong>: Specifies the maximum number of entries that |
| 35 | + * can be stored in the cache.</li> |
| 36 | + * <li><strong>autoCache</strong>: Determines whether caching should be |
| 37 | + * automatically applied when the method is invoked.</li> |
34 | 38 | * </ul>
|
35 | 39 | * </p>
|
36 | 40 | *
|
|
47 | 51 | * {@code
|
48 | 52 | * @LocalCache(durationInMinute = 15, maxRecord = 200, autoCache = true)
|
49 | 53 | * public List<User> fetchActiveUsers() {
|
50 |
| - * // Retrieves a list of active users from the database |
| 54 | + * // Retrieves a list of active users from the database |
51 | 55 | * }
|
52 | 56 | * }
|
53 | 57 | * </pre>
|
54 | 58 | *
|
55 | 59 | * <h3>Annotation Properties:</h3>
|
56 | 60 | * <dl>
|
57 | 61 | * <dt><strong>durationInMinute</strong></dt>
|
58 |
| - * <dd>Specifies how long (in minutes) the cache entry remains valid. Default is 120 minutes.</dd> |
| 62 | + * <dd>Specifies how long (in minutes) the cache entry remains valid. Default is |
| 63 | + * 120 minutes.</dd> |
59 | 64 | *
|
60 | 65 | * <dt><strong>maxRecord</strong></dt>
|
61 |
| - * <dd>Limits the number of records stored in the cache at any given time. Default is 1000 entries.</dd> |
| 66 | + * <dd>Limits the number of records stored in the cache at any given time. |
| 67 | + * Default is 1000 entries.</dd> |
62 | 68 | *
|
63 | 69 | * <dt><strong>autoCache</strong></dt>
|
64 |
| - * <dd>If set to <code>true</code>, caching is applied automatically whenever the method is executed. Default is <code>false</code>.</dd> |
| 70 | + * <dd>If set to <code>true</code>, caching is applied automatically whenever |
| 71 | + * the method is executed. Default is <code>false</code>.</dd> |
65 | 72 | * </dl>
|
66 | 73 | *
|
67 | 74 | * <h3>Best Practices:</h3>
|
68 | 75 | * <ul>
|
69 |
| - * <li>Use on methods that return frequently accessed and computationally expensive results.</li> |
70 |
| - * <li>Avoid applying to methods with frequently changing data to prevent stale cache issues.</li> |
71 |
| - * <li>Adjust `durationInMinute` and `maxRecord` according to system load and data update frequency.</li> |
| 76 | + * <li>Use on methods that return frequently accessed and computationally |
| 77 | + * expensive results.</li> |
| 78 | + * <li>Avoid applying to methods with frequently changing data to prevent stale |
| 79 | + * cache issues.</li> |
| 80 | + * <li>Adjust `durationInMinute` and `maxRecord` according to system load and |
| 81 | + * data update frequency.</li> |
72 | 82 | * </ul>
|
73 | 83 | *
|
74 | 84 | * <p>
|
75 |
| - * This annotation is particularly useful in microservices and high-performance applications |
76 |
| - * where minimizing latency and optimizing resource utilization are crucial. |
| 85 | + * This annotation is particularly useful in microservices and high-performance |
| 86 | + * applications where minimizing latency and optimizing resource utilization are |
| 87 | + * crucial. |
77 | 88 | * </p>
|
78 | 89 | */
|
79 | 90 | @Target(ElementType.METHOD)
|
|
89 | 100 | int durationInMinute() default 120;
|
90 | 101 |
|
91 | 102 | /**
|
92 |
| - * Specifies the maximum number of records that can be stored in the cache. |
93 |
| - * Once this limit is reached, older entries may be evicted based on cache policies. |
| 103 | + * Specifies the maximum number of records that can be stored in the cache. Once |
| 104 | + * this limit is reached, older entries may be evicted based on cache policies. |
94 | 105 | *
|
95 | 106 | * @return maximum cache size (default: 1000)
|
96 | 107 | */
|
97 | 108 | int maxRecord() default 1000;
|
98 | 109 |
|
99 | 110 | /**
|
100 |
| - * Indicates whether caching should be automatically applied when the method is invoked. |
101 |
| - * If enabled, the method execution result will be stored in the cache for subsequent calls. |
| 111 | + * Indicates whether caching should be automatically applied when the method is |
| 112 | + * invoked. If enabled, the method execution result will be stored in the cache |
| 113 | + * for subsequent calls. |
102 | 114 | *
|
103 |
| - * @return <code>true</code> to enable automatic caching, <code>false</code> otherwise (default: false) |
| 115 | + * @return <code>true</code> to enable automatic caching, <code>false</code> |
| 116 | + * otherwise (default: false) |
104 | 117 | */
|
105 | 118 | boolean autoCache() default false;
|
106 | 119 | }
|
0 commit comments