@@ -597,7 +597,7 @@ func createModelRoutes(config *config.Config,
597597 modelsGroup .GET ("" , cache .Cache (memoryStore , time .Minute , middleware .CacheStrategyTrendingRepos ()), modelHandler .Index )
598598 modelsGroup .PUT ("/:namespace/:name" , middlewareCollection .Auth .NeedLogin , modelHandler .Update )
599599 modelsGroup .DELETE ("/:namespace/:name" , middlewareCollection .Auth .NeedLogin , modelHandler .Delete )
600- modelsGroup .GET ("/:namespace/:name" , modelHandler .Show )
600+ modelsGroup .GET ("/:namespace/:name" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), modelHandler .Show )
601601 modelsGroup .GET ("/:namespace/:name/relations" , modelHandler .Relations )
602602 modelsGroup .PUT ("/:namespace/:name/relations" , middlewareCollection .Auth .NeedAdmin , modelHandler .SetRelations )
603603 modelsGroup .POST ("/:namespace/:name/relations/dataset" , middlewareCollection .Auth .NeedPhoneVerified , modelHandler .AddDatasetRelation )
@@ -611,7 +611,7 @@ func createModelRoutes(config *config.Config,
611611 modelsGroup .GET ("/:namespace/:name/tags" , repoCommonHandler .Tags )
612612 modelsGroup .POST ("/:namespace/:name/preupload/:revision" , middlewareCollection .Auth .NeedPhoneVerified , repoCommonHandler .Preupload )
613613 // update tags of a certain category
614- modelsGroup .GET ("/:namespace/:name/all_files" , repoCommonHandler .AllFiles )
614+ modelsGroup .GET ("/:namespace/:name/all_files" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), repoCommonHandler .AllFiles )
615615 modelsGroup .POST ("/:namespace/:name/tags/:category" , middlewareCollection .Auth .NeedPhoneVerified , repoCommonHandler .UpdateTags )
616616 modelsGroup .GET ("/:namespace/:name/last_commit" , repoCommonHandler .LastCommit )
617617 modelsGroup .GET ("/:namespace/:name/commit/:commit_id" , repoCommonHandler .CommitWithDiff )
@@ -623,7 +623,7 @@ func createModelRoutes(config *config.Config,
623623 modelsGroup .GET ("/:namespace/:name/refs/:ref/remote_tree/*path" , repoCommonHandler .RemoteTree )
624624 modelsGroup .GET ("/:namespace/:name/refs/:ref/logs_tree/*path" , repoCommonHandler .LogsTree )
625625 modelsGroup .GET ("/:namespace/:name/commits" , repoCommonHandler .Commits )
626- modelsGroup .GET ("/:namespace/:name/raw/*file_path" , repoCommonHandler .FileRaw )
626+ modelsGroup .GET ("/:namespace/:name/raw/*file_path" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), repoCommonHandler .FileRaw )
627627 modelsGroup .GET ("/:namespace/:name/blob/*file_path" , repoCommonHandler .FileInfo )
628628 // The DownloadFile method differs from the SDKDownload interface in a few ways
629629
@@ -735,6 +735,9 @@ func createDatasetRoutes(
735735 dsHandler * handler.DatasetHandler ,
736736 repoCommonHandler * handler.RepoHandler ,
737737) {
738+ // gin cache
739+ memoryStore := persist .NewMemoryStore (2 * time .Minute )
740+
738741 datasetsGroup := apiGroup .Group ("/datasets" )
739742 // allow access without login
740743 datasetsGroup .GET ("" , dsHandler .Index )
@@ -744,13 +747,13 @@ func createDatasetRoutes(
744747 datasetsGroup .POST ("" , middlewareCollection .Auth .NeedPhoneVerified , dsHandler .Create )
745748 datasetsGroup .PUT ("/:namespace/:name" , middleware .MustLogin (), dsHandler .Update )
746749 datasetsGroup .DELETE ("/:namespace/:name" , middleware .MustLogin (), dsHandler .Delete )
747- datasetsGroup .GET ("/:namespace/:name" , dsHandler .Show )
750+ datasetsGroup .GET ("/:namespace/:name" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), dsHandler .Show )
748751 datasetsGroup .GET ("/:namespace/:name/relations" , middleware .MustLogin (), dsHandler .Relations )
749752 datasetsGroup .GET ("/:namespace/:name/branches" , middleware .MustLogin (), repoCommonHandler .Branches )
750753 datasetsGroup .GET ("/:namespace/:name/tags" , middleware .MustLogin (), repoCommonHandler .Tags )
751754 datasetsGroup .POST ("/:namespace/:name/preupload/:revision" , middlewareCollection .Auth .NeedPhoneVerified , repoCommonHandler .Preupload )
752755 // update tags of a certain category
753- datasetsGroup .GET ("/:namespace/:name/all_files" , middleware .MustLogin (), repoCommonHandler .AllFiles )
756+ datasetsGroup .GET ("/:namespace/:name/all_files" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), middleware .MustLogin (), repoCommonHandler .AllFiles )
754757 datasetsGroup .POST ("/:namespace/:name/tags/:category" , middleware .MustLogin (), repoCommonHandler .UpdateTags )
755758 datasetsGroup .GET ("/:namespace/:name/last_commit" , repoCommonHandler .LastCommit )
756759 datasetsGroup .GET ("/:namespace/:name/commit/:commit_id" , middleware .MustLogin (), repoCommonHandler .CommitWithDiff )
@@ -763,7 +766,7 @@ func createDatasetRoutes(
763766 datasetsGroup .GET ("/:namespace/:name/refs/:ref/logs_tree/*path" , middleware .MustLogin (), repoCommonHandler .LogsTree )
764767 datasetsGroup .GET ("/:namespace/:name/commits" , middleware .MustLogin (), repoCommonHandler .Commits )
765768 datasetsGroup .POST ("/:namespace/:name/raw/*file_path" , middlewareCollection .Auth .NeedPhoneVerified , repoCommonHandler .CreateFile )
766- datasetsGroup .GET ("/:namespace/:name/raw/*file_path" , middleware .MustLogin (), repoCommonHandler .FileRaw )
769+ datasetsGroup .GET ("/:namespace/:name/raw/*file_path" , cache . Cache ( memoryStore , time . Minute * 2 , middleware . CacheRepoInfo ()), middleware .MustLogin (), repoCommonHandler .FileRaw )
767770 datasetsGroup .GET ("/:namespace/:name/blob/*file_path" , repoCommonHandler .FileInfo )
768771 datasetsGroup .GET ("/:namespace/:name/download/*file_path" , middleware .MustLogin (), repoCommonHandler .DownloadFile )
769772 datasetsGroup .GET ("/:namespace/:name/resolve/*file_path" , middleware .MustLogin (), repoCommonHandler .ResolveDownload )
0 commit comments