Annotation Type JCacheXCacheable
-
@Target(METHOD) @Retention(RUNTIME) @Inherited public @interface JCacheXCacheable
Annotation that indicates a method's result should be cached using JCacheX. This annotation provides declarative caching for Spring Boot applications, allowing method results to be automatically cached and retrieved without manual cache management. It integrates seamlessly with Spring's caching infrastructure while providing JCacheX-specific configuration options.Basic Usage Examples:
{ @code @Service public class UserService {
- Since:
- 1.0.0
- See Also:
JCacheXCacheEvict
,JCacheXProperties
,Cacheable
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description String
cacheName
The name of the cache to use.String
condition
The SpEL expression to determine if caching should occur.long
expireAfterWrite
The time after which the entry should expire after being written.TimeUnit
expireAfterWriteUnit
The time unit for expireAfterWrite.String
key
The SpEL expression to compute the cache key.long
maximumSize
The maximum number of entries in the cache.String
profile
The cache profile to use for optimized configuration.String
unless
The SpEL expression to determine if caching should NOT occur.
-
-
-
Element Detail
-
cacheName
String cacheName
The name of the cache to use. If empty, defaults to the fully qualified method name.- Returns:
- the cache name
- Default:
- ""
-
-
-
key
String key
The SpEL expression to compute the cache key. If empty, all method parameters are used.- Returns:
- the SpEL expression for the cache key
- Default:
- ""
-
-
-
condition
String condition
The SpEL expression to determine if caching should occur. Empty means always cache.- Returns:
- the SpEL expression for the condition
- Default:
- ""
-
-
-
unless
String unless
The SpEL expression to determine if caching should NOT occur. Empty means never skip caching.- Returns:
- the SpEL expression for the unless condition
- Default:
- ""
-
-
-
expireAfterWriteUnit
TimeUnit expireAfterWriteUnit
The time unit for expireAfterWrite.- Returns:
- the time unit for expiration
- Default:
- java.util.concurrent.TimeUnit.SECONDS
-
-
-
profile
String profile
The cache profile to use for optimized configuration. This allows you to specify pre-configured cache profiles that automatically select the optimal cache implementation, eviction strategy, and other settings based on the intended use case.Available Profiles:
- DEFAULT: General-purpose cache for most use cases
- READ_HEAVY: Optimized for read-intensive workloads
- WRITE_HEAVY: Optimized for write-intensive workloads
- MEMORY_EFFICIENT: Minimizes memory usage
- HIGH_PERFORMANCE: Maximum performance optimization
- SESSION_CACHE: Optimized for session storage
- API_CACHE: Optimized for API response caching
- COMPUTE_CACHE: Optimized for expensive computations
- ML_OPTIMIZED: Machine learning optimized with predictive capabilities
- ZERO_COPY: Zero-copy optimized for minimal memory allocation
- HARDWARE_OPTIMIZED: Hardware-optimized leveraging CPU features
- DISTRIBUTED: Distributed cache for cluster environments
Profile Usage Examples:
{ @code @Service public class UserService { // Read-heavy workload - users are read frequently @JCacheXCacheable(value = "users", profile = "READ_HEAVY") public User findUserById(String id) { return userRepository.findById(id); } // API response caching with TTL @JCacheXCacheable(value = "api-data", profile = "API_CACHE", expireAfterWrite = 15, expireAfterWriteUnit = TimeUnit.MINUTES) public ApiResponse getApiData(String endpoint) { return apiClient.call(endpoint); } // Memory-efficient for large datasets
- Returns:
- the cache profile name, empty string means use default configuration
- Default:
- ""
-
-