Skip to content

Commit 69f8f7a

Browse files
author
Yang Guo
committed
add cache for tags
1 parent bd26532 commit 69f8f7a

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

platform-api/src/main/java/com/flow/platform/api/controller/FlowController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public List<String> listBranches(@RequestParam(required = false) Boolean refresh
271271
@GetMapping("/{root}/tags")
272272
public List<String> listTags() {
273273
Node root = nodeService.find(currentNodePath.get());
274-
return gitService.tags(root);
274+
return gitService.tags(root, false);
275275
}
276276

277277
/**

platform-api/src/main/java/com/flow/platform/api/service/GitService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ interface ProgressListener {
6666
/**
6767
* Fetch tags from git repo
6868
*/
69-
List<String> tags(Node node);
69+
List<String> tags(Node node, boolean refresh);
7070

7171
/**
7272
* Fetch latest commit from git repo

platform-api/src/main/java/com/flow/platform/api/service/GitServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public List<String> branches(Node node, boolean refresh) {
113113
}
114114

115115
@Override
116-
public List<String> tags(Node node) {
116+
@Cacheable(value = "git.tags", key = "#node.getPath()", condition = "#refresh == false")
117+
public List<String> tags(Node node, boolean refresh) {
117118
GitClient client = gitClientInstance(node);
118119
try {
119120
return client.tags();

platform-api/src/test/java/com/flow/platform/api/test/service/GitServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void should_list_branches_of_git_repo() {
110110

111111
@Test
112112
public void should_list_tags_of_git_repo() {
113-
List<String> tags = gitService.tags(node);
113+
List<String> tags = gitService.tags(node, false);
114114
Assert.assertNotNull(tags);
115115
}
116116

0 commit comments

Comments
 (0)