private StartupShutdownBase CreateLocalServer(LocalServerConfiguration localServerConfiguration, DistributedContentSettings distributedSettings = null) { var resolvedCacheSettings = DistributedContentStoreFactory.ResolveCacheSettingsInPrecedenceOrder(_arguments); Func <AbsolutePath, IContentStore> contentStoreFactory = path => DistributedContentStoreFactory.CreateLocalContentStore( distributedSettings, _arguments, resolvedCacheSettings.Where(s => s.ResolvedCacheRootPath == path || s.ResolvedCacheRootPath.Path.StartsWith(path.Path, StringComparison.OrdinalIgnoreCase)).Single()); if (distributedSettings?.EnableMetadataStore == true) { _logger.Always("Creating local server with content and metadata store"); var factory = CreateDistributedContentStoreFactory(); Func <AbsolutePath, ICache> cacheFactory = path => { var distributedCache = new OneLevelCache( contentStoreFunc: () => contentStoreFactory(path), memoizationStoreFunc: () => CreateServerSideLocalMemoizationStore(path, factory), Guid.NewGuid(), passContentToMemoization: true); ICache cacheToReturn = distributedCache; #if MICROSOFT_INTERNAL if (distributedSettings.EnablePublishingCache) { cacheToReturn = new PublishingCache <OneLevelCache>( local: distributedCache, remote: new BuildCachePublishingStore(contentSource: distributedCache, _fileSystem, distributedSettings.PublishingConcurrencyLimit), Guid.NewGuid()); } #endif return(cacheToReturn); }; return(new LocalCacheServer( _fileSystem, _logger, _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName, cacheFactory, localServerConfiguration, capabilities: distributedSettings.EnablePublishingCache?Capabilities.All: Capabilities.AllNonPublishing)); } else { _logger.Always("Creating local server with content store only"); return(new LocalContentServer( _fileSystem, _logger, _arguments.Configuration.LocalCasSettings.ServiceSettings.ScenarioName, contentStoreFactory, localServerConfiguration)); } }
private ICache CreateBlockingPublishingCache(AbsolutePath path) { var configuration = ContentStoreConfiguration.CreateWithMaxSizeQuotaMB(1); var configurationModel = new ConfigurationModel(configuration); var contentStore = new FileSystemContentStore(FileSystem, SystemClock.Instance, path, configurationModel); var localCache = new OneLevelCache( () => contentStore, () => new MemoryMemoizationStore(Logger), CacheDeterminism.NewCacheGuid()); return(new PublishingCacheToContentStore(new PublishingCache <OneLevelCache>(localCache, new BlockingPublishingStore(), Guid.NewGuid()))); }