Skip to content

Commit

Permalink
setup redis
Browse files Browse the repository at this point in the history
  • Loading branch information
mohaijiang committed Mar 14, 2024
1 parent 98b0681 commit dde67fb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/service/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,17 @@ func (p *ProjectService) UpdateProjectBranch(id string, userId int64, branch str

func (p *ProjectService) getProjectBranches(repositoryUrl string, token string) ([]string, error) {

fmt.Println("getProjectBranches")
key := fmt.Sprintf("PROJECT_BRANCH:%s", repositoryUrl)

ctx := context.Background()
exists, err := p.rdb.Exists(ctx, key).Result()

if exists == 0 || err != nil {
fmt.Println("exists:", exists)
fmt.Println("exists err : ", err)

if exists == 0 {
fmt.Println("api query github repo branch")
// branches
githubService := application.GetBean[*GithubService]("githubService")
ctx, _ := context.WithTimeout(context.Background(), time.Second*20)
Expand All @@ -529,6 +534,7 @@ func (p *ProjectService) getProjectBranches(repositoryUrl string, token string)
}

} else {
fmt.Println("redis query github repo branch")
branches, err := p.rdb.LRange(ctx, key, 0, -1).Result()
if err != nil {
return nil, err
Expand Down

0 comments on commit dde67fb

Please sign in to comment.