File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Gttsb . Core ;
22using Gttsb . Gh ;
3+ using Microsoft . Extensions . Caching . Memory ;
34
45var builder = WebApplication . CreateBuilder ( args ) ;
56
67// Add services to the container.
78builder . Services . Configure < AppOptions > ( builder . Configuration . GetSection ( "GitHubApp" ) ) ;
89builder . Services . Configure < AzureOptions > ( builder . Configuration . GetSection ( "Azure" ) ) ;
10+ builder . Services . AddSingleton < IMemoryCache > ( new MemoryCache ( new MemoryCacheOptions ( ) ) ) ;
911
1012builder . Services . AddSingleton < IGitHubFacadeFactory , GitHubFacadeFactory > ( ) ;
1113builder . Services . AddSingleton < IActiveDirectoryFacadeFactory , ActiveDirectoryFacadeFactory > ( ) ;
Original file line number Diff line number Diff line change 11using Gttsb . Core ;
2+ using Microsoft . Extensions . Caching . Memory ;
23using Microsoft . Extensions . Options ;
34using Microsoft . IdentityModel . Tokens ;
45using Octokit ;
@@ -11,10 +12,12 @@ namespace Gttsb.Gh
1112 public sealed class GitHubFacadeFactory : IGitHubFacadeFactory
1213 {
1314 private readonly IOptions < AppOptions > options ;
15+ private IMemoryCache cache ;
1416
15- public GitHubFacadeFactory ( IOptions < AppOptions > options )
17+ public GitHubFacadeFactory ( IOptions < AppOptions > options , IMemoryCache cache )
1618 {
1719 this . options = options ;
20+ this . cache = cache ;
1821 }
1922
2023 private IGitHubClient GetInitialClient ( AppOptions options )
@@ -48,7 +51,11 @@ public async Task<IInstalledGitHubFacade> CreateClientForOrgAsync(Core.Installat
4851
4952 var connection = new Octokit . GraphQL . Connection ( new Octokit . GraphQL . ProductHeaderValue ( productHeaderName ) , response . Token ) ;
5053
51- return new InstalledGitHubFacade ( installationClient , connection , installation . OrgName ) ;
54+ var installedClient = new InstalledGitHubFacade ( installationClient , connection , installation . OrgName ) ;
55+
56+ var withCacheDecorator = new GitHubFacadeCacheDecorator ( installedClient , cache ) ;
57+
58+ return withCacheDecorator ;
5259 }
5360
5461 public async Task < IEnumerable < Core . Installation > > GetInstallationsAsync ( )
You can’t perform that action at this time.
0 commit comments