Skip to content

Commit f880fcf

Browse files
committed
修改示例中的一些配置
1 parent 331713e commit f880fcf

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
```
1313

1414

15-
## 使用
15+
## 使用
1616

1717
本注解需要与下面两套注解搭配使用,以实现对被注解参数所在的方法进行批量的缓存操作。
1818

@@ -139,7 +139,7 @@ class FooService {
139139
}
140140
```
141141

142-
### 与其他注解搭配使用时的说明
142+
### 与其他注解搭配使用时的说明
143143
* 与 Spring 的 `@CachePut` 搭配时,同样符合上面的例子。
144144
*`@CacheEvict` 搭配时,若注解的 `@CacheEvict.key()` 参数中没有 `#result`,对【方法】返回类型无要求;若 key 中有 `#result`,【方法】返回类型需要是 `Map``List`
145145
* 与 Spring 的 `@CachePut``@CacheEvict` 搭配,若 key 参数中已有 `#result`, 则可以没有【对象集合参数】的引用。
@@ -211,7 +211,7 @@ class FooService {
211211
}
212212
```
213213

214-
### 总结和补充
214+
### 总结和补充
215215
1. `@CacheAsMulti` 注解不能替代 Spring 缓存注解中的 key 参数,例如:`@Cacheable.key()`,也不能替代 `@CacheKey``@CacheValue` 注解。
216216
2. 如果使用自定义的 `KeyGenerator`,则会用【对象集合参数】的每个【元素】和其他参数组成 `Object[]` 传入 `KeyGenerator.generate(Object, Method, Object...)` 计算缓存 key;自定义的 `CacheKeyGenerator` 也一样。
217217
3. 与生成缓存的注解搭配使用时,若方法的返回类型是 `Map`,【元素】在 `Map` 中对应的值为 `null` 就会缓存 `null`,【元素】在 `Map` 中不存在就不缓存。

cache-as-multi-sample/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@
1010
</parent>
1111
<artifactId>cache-as-multi-sample</artifactId>
1212

13-
<name>cache-as-multi-sample</name>
14-
<!-- FIXME change it to the project's website -->
15-
<url>http://www.example.com</url>
16-
1713
<properties>
1814
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1915
<maven.compiler.source>1.8</maven.compiler.source>
2016
<maven.compiler.target>1.8</maven.compiler.target>
2117
<spring-boot.version>2.6.8</spring-boot.version>
2218
</properties>
2319

24-
2520
<dependencies>
2621
<dependency>
2722
<groupId>org.springframework.boot</groupId>
@@ -42,17 +37,15 @@
4237
<dependency>
4338
<groupId>org.springframework.boot</groupId>
4439
<artifactId>spring-boot-starter-cache</artifactId>
45-
<scope>provided</scope>
4640
</dependency>
4741
<dependency>
4842
<groupId>org.springframework.boot</groupId>
4943
<artifactId>spring-boot-starter-data-redis</artifactId>
50-
<optional>true</optional>
5144
</dependency>
5245
<dependency>
5346
<groupId>io.github.ms100</groupId>
5447
<artifactId>cache-as-multi</artifactId>
55-
<version>1.0.0</version>
48+
<version>1.1.3</version>
5649
</dependency>
5750
<!-- test -->
5851
<dependency>

cache-as-multi-sample/src/main/java/io/github/ms100/cacheasmultisample/cache/DogController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public Dog getDog(@RequestParam("id") Long dogId) {
2525

2626

2727
@RequestMapping("/getDogs")
28-
public Map<Long, Dog> getDogs(@RequestParam("ids") Long[] dogIds) {
28+
public Map<Long, Dog> getDogs(@RequestParam("id") Long[] dogIds) {
2929
return dogService.getDogs(Arrays.asList(dogIds));
3030
}
3131

3232
@RequestMapping("/getDogList")
33-
public List<Dog> getDogList(@RequestParam("ids") Long[] dogIds) {
33+
public List<Dog> getDogList(@RequestParam("id") Long[] dogIds) {
3434
return dogService.getDogList(Arrays.asList(dogIds));
3535
}
3636

cache-as-multi-sample/src/main/java/io/github/ms100/cacheasmultisample/cache/service/DogServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@RequiredArgsConstructor
1717
@Slf4j
1818
@CacheConfig(cacheNames = "dog")
19-
class DogServiceImpl implements DogService {
19+
public class DogServiceImpl implements DogService {
2020

2121
@Override
2222
@Cacheable

cache-as-multi/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<url>https://github.com/ms100/cache-as-multi</url>
1212
<description>
1313
Enhance spring cache annotation and realize the batch data caching.
14+
扩展 Spring Cache 实现批量数据的缓存。
1415
</description>
1516

1617
<inceptionYear>2023</inceptionYear>
@@ -29,7 +30,7 @@
2930
</scm>
3031
<developers>
3132
<developer>
32-
<name>zhumengshuai</name>
33+
<name>Zhu Mengshuai</name>
3334
<email>[email protected]</email>
3435
</developer>
3536
</developers>

0 commit comments

Comments
 (0)