|
10 | 10 | @CacheConfig("addressDemo") |
11 | 11 | public class CustomerDataService { |
12 | 12 |
|
13 | | - /** The cache manager. */ |
14 | | - @Autowired |
15 | | - CacheManager cacheManager; |
| 13 | + /** The cache manager. */ |
| 14 | + @Autowired |
| 15 | + CacheManager cacheManager; |
16 | 16 |
|
17 | | - /** |
18 | | - * The method returns the customer's address, |
19 | | - only it doesn't find it the cache- addresses and directory. |
20 | | - * |
21 | | - * @param customer the customer |
22 | | - * @return the address |
23 | | - */ |
| 17 | + /** |
| 18 | + * The method returns the customer's address, |
| 19 | + only it doesn't find it the cache- addresses and directory. |
| 20 | + * |
| 21 | + * @param customer the customer |
| 22 | + * @return the address |
| 23 | + */ |
24 | 24 |
|
25 | | - @Cacheable("addresses", “directory”) |
| 25 | + @Cacheable("addresses", “directory”) |
26 | 26 |
|
27 | | - public String getAddress1(Customer customer) { |
| 27 | + public String getAddress1(Customer customer) { |
28 | 28 |
|
29 | | - return customer.getAddress(); |
30 | | - } |
| 29 | + return customer.getAddress(); |
| 30 | + } |
31 | 31 |
|
32 | | - /** |
33 | | - * The method returns the customer's address, |
34 | | - but refreshes all the entries in the cache to load new ones. |
35 | | - * |
36 | | - * @param customer the customer |
37 | | - * @return the address |
38 | | - */ |
| 32 | + /** |
| 33 | + * The method returns the customer's address, |
| 34 | + but refreshes all the entries in the cache to load new ones. |
| 35 | + * |
| 36 | + * @param customer the customer |
| 37 | + * @return the address |
| 38 | + */ |
39 | 39 |
|
40 | | - @CacheEvict(value="addresses", allEntries=true) |
| 40 | + @CacheEvict(value="addresses", allEntries=true) |
41 | 41 |
|
42 | | - public String getAddress2(Customer customer) { |
| 42 | + public String getAddress2(Customer customer) { |
43 | 43 |
|
44 | | - return customer.getAddress(); |
45 | | - } |
| 44 | + return customer.getAddress(); |
| 45 | + } |
46 | 46 |
|
47 | | - /** |
48 | | - * The method returns the customer's address, |
49 | | - but not before selectively evicting the cache as per specified paramters. |
50 | | - * |
51 | | - * @param customer the customer |
52 | | - * @return the address |
53 | | - */ |
| 47 | + /** |
| 48 | + * The method returns the customer's address, |
| 49 | + but not before selectively evicting the cache as per specified paramters. |
| 50 | + * |
| 51 | + * @param customer the customer |
| 52 | + * @return the address |
| 53 | + */ |
54 | 54 |
|
55 | | - @Caching(evict = { @CacheEvict("addresses"), @CacheEvict(value="directory", key="customer.name") }) |
| 55 | + @Caching(evict = { @CacheEvict("addresses"), @CacheEvict(value="directory", key="customer.name") }) |
56 | 56 |
|
57 | | - public String getAddress3(Customer customer) { |
| 57 | + public String getAddress3(Customer customer) { |
58 | 58 |
|
59 | | - return customer.getAddress(); |
60 | | - } |
| 59 | + return customer.getAddress(); |
| 60 | + } |
61 | 61 |
|
62 | | - /** |
63 | | - * The method uses the class level cache to look up for entries. |
64 | | - * |
65 | | - * @param customer the customer |
66 | | - * @return the address |
67 | | - */ |
| 62 | + /** |
| 63 | + * The method uses the class level cache to look up for entries. |
| 64 | + * |
| 65 | + * @param customer the customer |
| 66 | + * @return the address |
| 67 | + */ |
68 | 68 |
|
69 | | - @Cacheable // parameter not required as we have declared it using @CacheConfig |
| 69 | + @Cacheable // parameter not required as we have declared it using @CacheConfig |
70 | 70 |
|
71 | | - public String getAddress4(Customer customer) { |
| 71 | + public String getAddress4(Customer customer) { |
72 | 72 |
|
73 | | - return customer.getAddress(); |
74 | | - } |
| 73 | + return customer.getAddress(); |
| 74 | + } |
75 | 75 |
|
76 | | - /** |
77 | | - * The method selectively caches the results that meet the predefined criteria. |
78 | | - * |
79 | | - * @param customer the customer |
80 | | - * @return the address |
81 | | - */ |
| 76 | + /** |
| 77 | + * The method selectively caches the results that meet the predefined criteria. |
| 78 | + * |
| 79 | + * @param customer the customer |
| 80 | + * @return the address |
| 81 | + */ |
82 | 82 |
|
83 | 83 |
|
84 | | - @CachePut(value="addresses", condition=”#customer.name=’Tom’”) |
85 | | - @CachePut(value="addresses", unless=”#result.length>64”) |
| 84 | + @CachePut(value="addresses", condition=”#customer.name=’Tom’”) |
| 85 | + @CachePut(value="addresses", unless=”#result.length>64”) |
86 | 86 |
|
87 | | - public String getAddress5(Customer customer) { |
| 87 | + public String getAddress5(Customer customer) { |
88 | 88 |
|
89 | | - return customer.getAddress(); |
90 | | - } |
| 89 | + return customer.getAddress(); |
| 90 | + } |
91 | 91 |
|
92 | 92 |
|
93 | 93 | } |
0 commit comments