Example #1
0
        private Task <BoolResult> CreateDistributedMemoizationStoreAsync(OperationContext context)
        {
            return(context.PerformOperationAsync(Tracer, async() =>
            {
                if (!_distributedContentStore.TryGetLocalLocationStore(out var localLocationStore))
                {
                    return new BoolResult("LocalLocationStore not available");
                }

                var memoizationStoreConfiguration = localLocationStore.Configuration as RedisMemoizationStoreConfiguration;
                if (memoizationStoreConfiguration == null)
                {
                    return new BoolResult($"LocalLocationStore.Configuration should be of type 'RedisMemoizationStoreConfiguration' but was {localLocationStore.Configuration.GetType()}");
                }

                var redisStore = (RedisGlobalStore)localLocationStore.GlobalStore;

                MemoizationStore = new DatabaseMemoizationStore(
                    new DistributedMemoizationDatabase(
                        localLocationStore,
                        new RedisMemoizationDatabase(
                            redisStore.RaidedRedis,
                            localLocationStore.EventStore.Clock,
                            memoizationStoreConfiguration.LocationEntryExpiry,
                            memoizationStoreConfiguration.MemoizationOperationTimeout,
                            memoizationStoreConfiguration.MemoizationSlowOperationCancellationTimeout)));

                return await MemoizationStore.StartupAsync(context);
            }));
Example #2
0
        /// <nodoc />
        public ReadOnlyDatabaseMemoizationSession(string name, DatabaseMemoizationStore memoizationStore)
        {
            Contract.RequiresNotNull(name);
            Contract.RequiresNotNull(memoizationStore);

            Tracer           = new Tracer(name);
            Name             = name;
            MemoizationStore = memoizationStore;
        }
Example #3
0
        /// <nodoc />
        public ReadOnlyDatabaseMemoizationSession(string name, DatabaseMemoizationStore memoizationStore)
        {
            Contract.Requires(name != null);
            Contract.Requires(memoizationStore != null);

            Tracer           = new Tracer(nameof(ReadOnlyDatabaseMemoizationSession));
            Name             = name;
            MemoizationStore = memoizationStore;
        }
Example #4
0
        private Task <BoolResult> CreateDistributedMemoizationStoreAsync(OperationContext context)
        {
            return(context.PerformOperationAsync(Tracer, async() =>
            {
                if (!_distributedContentStore.TryGetLocalLocationStore(out var localLocationStore))
                {
                    return new BoolResult("LocalLocationStore not available");
                }

                var redisStore = (RedisGlobalStore)localLocationStore.GlobalStore;

                MemoizationStore = new DatabaseMemoizationStore(new DistributedMemoizationDatabase(
                                                                    localLocationStore,
                                                                    new RedisMemoizationDatabase(redisStore.RedisDatabase, localLocationStore.EventStore.Clock, localLocationStore.Configuration.LocationEntryExpiry)));

                return await MemoizationStore.StartupAsync(context);
            }));
Example #5
0
        private Task <BoolResult> CreateDistributedMemoizationStoreAsync(OperationContext context)
        {
            return(context.PerformOperationAsync(base.Tracer, async() =>
            {
                MemoizationDatabase getGlobalMemoizationDatabase()
                {
                    if (_contentLocationStoreServices.Configuration.UseMemoizationContentMetadataStore)
                    {
                        return new MetadataStoreMemoizationDatabase(_contentLocationStoreServices.GlobalCacheStore.Instance);
                    }
                    else
                    {
                        var redisStore = _contentLocationStoreServices.RedisGlobalStore.Instance;
                        return new RedisMemoizationDatabase(redisStore.RaidedRedis, _contentLocationStoreServices.Configuration.Memoization);
                    }
                }

                MemoizationStore = new DatabaseMemoizationStore(
                    new DistributedMemoizationDatabase(
                        _contentLocationStoreServices.LocalLocationStore.Instance,
                        getGlobalMemoizationDatabase()));

                return await MemoizationStore.StartupAsync(context);
            }));
Example #6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="DatabaseMemoizationSession" /> class.
 /// </summary>
 /// <remarks>
 ///     Allowing contentSession to be null to allow the creation of uncoupled MemoizationSessions.
 ///     While we might extend this to the actual interface at some point, for now it's just a test hook
 ///     to compare to the previous behavior.  With a null content session, metadata will be automatically
 ///     overwritten because we're unable to check whether or not content is missing.
 /// </remarks>
 public DatabaseMemoizationSession(string name, DatabaseMemoizationStore memoizationStore, IContentSession contentSession = null)
     : base(name, memoizationStore)
 {
     _contentSession = contentSession;
 }