/// <inheritdoc /> public Task <IContentLocationStore> CreateAsync(MachineLocation localMachineLocation) { IContentLocationStore contentLocationStore = null; if (Configuration.HasReadOrWriteMode(ContentLocationMode.Redis)) { var redisDatabaseAdapter = CreateDatabase(RedisDatabaseFactoryForContent); var machineLocationRedisDatabaseAdapter = CreateDatabase(RedisDatabaseFactoryForMachineLocations); contentLocationStore = new RedisContentLocationStore( redisDatabaseAdapter, machineLocationRedisDatabaseAdapter, Clock, _contentHashBumpTime, localMachineLocation.Data, Configuration); } if (Configuration.HasReadOrWriteMode(ContentLocationMode.LocalLocationStore)) { Contract.Assert(RedisDatabaseFactoryForRedisGlobalStore != null); var redisDatabaseForGlobalStore = CreateDatabase(RedisDatabaseFactoryForRedisGlobalStore); var secondaryRedisDatabaseForGlobalStore = CreateDatabase(RedisDatabaseFactoryForRedisGlobalStoreSecondary, optional: true); IGlobalLocationStore globalStore = new RedisGlobalStore(Clock, Configuration, localMachineLocation, redisDatabaseForGlobalStore, secondaryRedisDatabaseForGlobalStore); var localLocationStore = new LocalLocationStore(Clock, globalStore, Configuration); contentLocationStore = new TransitioningContentLocationStore(Configuration, (RedisContentLocationStore)contentLocationStore, localLocationStore, Clock); } return(Task.FromResult(contentLocationStore)); }
/// <inheritdoc /> public Task <IContentLocationStore> CreateAsync(MachineLocation localMachineLocation, ILocalContentStore localContentStore) { IContentLocationStore contentLocationStore = null; if (Configuration.HasReadOrWriteMode(ContentLocationMode.Redis)) { var redisDatabaseAdapter = CreateDatabase(RedisDatabaseFactoryForContent, "RedisDatabaseFactoryForContent"); var machineLocationRedisDatabaseAdapter = CreateDatabase(RedisDatabaseFactoryForMachineLocations, "RedisDatabaseFactoryForMachineLocations"); contentLocationStore = new RedisContentLocationStore( redisDatabaseAdapter, machineLocationRedisDatabaseAdapter, Clock, _contentHashBumpTime, localMachineLocation.Data, Configuration); } if (Configuration.HasReadOrWriteMode(ContentLocationMode.LocalLocationStore)) { var localLocationStore = _lazyLocalLocationStore.Value; contentLocationStore = new TransitioningContentLocationStore(Configuration, (RedisContentLocationStore)contentLocationStore, localLocationStore, localMachineLocation, localContentStore); } return(Task.FromResult(contentLocationStore)); }
/// <summary> /// Initializes a new instance of the <see cref="RedisContentLocationStoreFactory"/> class. /// </summary> public RedisContentLocationStoreFactory( /*CanBeNull*/ IConnectionStringProvider contentConnectionStringProvider, /*CanBeNull*/ IConnectionStringProvider machineLocationConnectionStringProvider, IClock clock, TimeSpan contentHashBumpTime, RedisContentLocationStoreConfiguration configuration, IDistributedContentCopier copier) { Contract.Requires(configuration != null); Contract.Requires(!string.IsNullOrWhiteSpace(configuration.Keyspace)); _contentConnectionStringProvider = contentConnectionStringProvider; _machineConnectionStringProvider = machineLocationConnectionStringProvider; Clock = clock; _contentHashBumpTime = contentHashBumpTime; _copier = copier; _lazyLocalLocationStore = new Lazy <LocalLocationStore>(() => CreateLocalLocationStore()); Configuration = configuration; if (Configuration.HasReadOrWriteMode(ContentLocationMode.Redis)) { Contract.Assert(contentConnectionStringProvider != null, "When ReadFromRedis is on 'contentConnectionStringProvider' must not be null."); Contract.Assert(machineLocationConnectionStringProvider != null, "When ReadFromRedis is on 'machineLocationConnectionStringProvider' must not be null."); } }
/// <summary> /// Initializes a new instance of the <see cref="RedisContentLocationStoreFactory"/> class. /// </summary> public RedisContentLocationStoreFactory( /*CanBeNull*/ IConnectionStringProvider contentConnectionStringProvider, /*CanBeNull*/ IConnectionStringProvider machineLocationConnectionStringProvider, IClock clock, TimeSpan contentHashBumpTime, string keySpace, byte[] localMachineLocation, IAbsFileSystem fileSystem = null, RedisContentLocationStoreConfiguration configuration = null) { Contract.Requires(!string.IsNullOrWhiteSpace(keySpace)); _contentConnectionStringProvider = contentConnectionStringProvider; _machineConnectionStringProvider = machineLocationConnectionStringProvider; _clock = clock; _contentHashBumpTime = contentHashBumpTime; _keySpace = keySpace + Salt; _localMachineLocation = localMachineLocation; _configuration = configuration ?? RedisContentLocationStoreConfiguration.Default; if (_configuration.HasReadOrWriteMode(ContentLocationMode.Redis)) { Contract.Assert(contentConnectionStringProvider != null, "When ReadFromRedis is on 'contentConnectionStringProvider' must not be null."); Contract.Assert(machineLocationConnectionStringProvider != null, "When ReadFromRedis is on 'machineLocationConnectionStringProvider' must not be null."); } }