private LocalCache(
     ILogger logger,
     AbsolutePath rootPath,
     IAbsFileSystem fileSystem,
     IClock clock,
     ConfigurationModel configurationModel,
     SQLiteMemoizationStoreConfiguration memoConfig,
     ContentStoreSettings contentStoreSettings,
     LocalCacheConfiguration localCacheConfiguration)
     : base(
         () => localCacheConfiguration.EnableContentServer
             ? (IContentStore) new ServiceClientContentStore(
             logger,
             fileSystem,
             localCacheConfiguration.CacheName,
             new ServiceClientRpcConfiguration(localCacheConfiguration.GrpcPort),
             (uint)localCacheConfiguration.RetryIntervalSeconds,
             (uint)localCacheConfiguration.RetryCount,
             scenario: localCacheConfiguration.ScenarioName)
             : new FileSystemContentStore(
             fileSystem,
             clock,
             rootPath,
             configurationModel: configurationModel,
             settings: contentStoreSettings),
         () => new SQLiteMemoizationStore(
             logger,
             clock ?? SystemClock.Instance,
             memoConfig),
         PersistentId.Load(fileSystem, rootPath / IdFileName))
 {
     _fileSystem = fileSystem;
 }
Exemple #2
0
        /// <summary>
        ///     Content Stores:
        ///         - <see cref="ServiceClientContentStore"/> if <see cref="LocalCacheConfiguration.EnableContentServer"/>
        ///         - <see cref="FileSystemContentStore"/> otherwise
        ///     Memoization Stores:
        ///         - <see cref="CreateInProcessLocalMemoizationStoreFactory(ILogger, IClock, MemoizationStoreConfiguration)"/>
        /// </summary>
        public static LocalCache CreateUnknownContentStoreInProcMemoizationStoreCache(
            ILogger logger,
            AbsolutePath rootPath,
            MemoizationStoreConfiguration memoizationStoreConfiguration,
            LocalCacheConfiguration localCacheConfiguration,
            ConfigurationModel configurationModel = null,
            IClock clock         = null,
            bool checkLocalFiles = true,
            bool emptyFileHashShortcutEnabled = false)
        {
            clock = clock ?? SystemClock.Instance;

            var fileSystem           = new PassThroughFileSystem(logger);
            var contentStoreSettings = new ContentStoreSettings()
            {
                CheckFiles = checkLocalFiles,
                UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled
            };

            Func <IContentStore> contentStoreFactory = () =>
            {
                if (localCacheConfiguration.EnableContentServer)
                {
                    return(new ServiceClientContentStore(
                               logger,
                               fileSystem,
                               localCacheConfiguration.CacheName,
                               new ServiceClientRpcConfiguration(localCacheConfiguration.GrpcPort),
                               (uint)localCacheConfiguration.RetryIntervalSeconds,
                               (uint)localCacheConfiguration.RetryCount,
                               scenario: localCacheConfiguration.ScenarioName));
                }
                else
                {
                    return(new FileSystemContentStore(
                               fileSystem,
                               clock,
                               rootPath,
                               configurationModel: configurationModel,
                               settings: contentStoreSettings));
                }
            };

            var memoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoizationStoreConfiguration);

            return(new LocalCache(fileSystem, contentStoreFactory, memoizationStoreFactory, LoadPersistentCacheGuid(rootPath, fileSystem)));
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="LocalCache" /> class backed by <see cref="FileSystemContentStore"/>
 /// </summary>
 public LocalCache(
     ILogger logger,
     AbsolutePath rootPath,
     SQLiteMemoizationStoreConfiguration memoConfig,
     LocalCacheConfiguration localCacheConfiguration,
     ConfigurationModel configurationModel = null,
     IClock clock         = null,
     bool checkLocalFiles = true,
     bool emptyFileHashShortcutEnabled = false)
     : this(
         logger,
         rootPath,
         new PassThroughFileSystem(logger),
         clock ?? SystemClock.Instance,
         configurationModel,
         memoConfig,
         new ContentStoreSettings() { CheckFiles = checkLocalFiles, UseEmptyFileHashShortcut = emptyFileHashShortcutEnabled },
         localCacheConfiguration)
 {
 }
Exemple #4
0
        /// <summary>
        ///     Content Stores:
        ///         - <see cref="ServiceClientContentStore"/> if <see cref="LocalCacheConfiguration.ServiceClientContentStoreConfiguration"/>
        ///         - <see cref="FileSystemContentStore"/> otherwise
        ///     Memoization Stores:
        ///         - <see cref="CreateInProcessLocalMemoizationStoreFactory(ILogger, IClock, MemoizationStoreConfiguration)"/>
        /// </summary>
        public static LocalCache CreateUnknownContentStoreInProcMemoizationStoreCache(
            ILogger logger,
            AbsolutePath rootPath,
            MemoizationStoreConfiguration memoizationStoreConfiguration,
            LocalCacheConfiguration localCacheConfiguration,
            ConfigurationModel configurationModel = null,
            IClock clock         = null,
            bool checkLocalFiles = true)
        {
            clock = clock ?? SystemClock.Instance;

            var fileSystem           = new PassThroughFileSystem(logger);
            var contentStoreSettings = new ContentStoreSettings()
            {
                CheckFiles = checkLocalFiles,
            };

            Func <IContentStore> contentStoreFactory = () =>
            {
                if (localCacheConfiguration.ServiceClientContentStoreConfiguration != null)
                {
                    return(new ServiceClientContentStore(logger, fileSystem, localCacheConfiguration.ServiceClientContentStoreConfiguration));
                }
                else
                {
                    return(new FileSystemContentStore(
                               fileSystem,
                               clock,
                               rootPath,
                               configurationModel: configurationModel,
                               settings: contentStoreSettings));
                }
            };

            var memoizationStoreFactory = CreateInProcessLocalMemoizationStoreFactory(logger, clock, memoizationStoreConfiguration);

            return(new LocalCache(fileSystem, contentStoreFactory, memoizationStoreFactory, LoadPersistentCacheGuid(rootPath, fileSystem)));
        }