public static IEventSourcingConfiguration WithComplexAggregateCache(this IEventSourcingConfiguration configuration)
 {
     return(configuration.WithRedisAggregateCache()
            .WithAggregateCache(typeof(AggregateCache <>), builder =>
     {
         builder
         .RegisterGeneric(typeof(InMemoryAggregateCache <>))
         .As(typeof(IInMemoryAggregateCache <>))
         .SingleInstance();
     }));
 }
Exemple #2
0
        public static IEventSourcingConfiguration WithEventStoreAsES(
            this IEventSourcingConfiguration configuration
            )
        {
            return(configuration.WithEventStore <EventStore.EventStore>((builder, config) =>
            {
                var eventStoreConfig = new EventStoreConfiguration(config);

                builder.WithEventStoreDatabase(eventStoreConfig);
                builder.RegisterType <EventConverter>().AsSelf().SingleInstance();
            }));
        }
        public static IEventSourcingConfiguration WithRedisAggregateCache(this IEventSourcingConfiguration eventSourcingConfiguration)
        {
            return(eventSourcingConfiguration.WithAggregateCache(
                       typeof(RedisAggregateCache <>),
                       (builder, config) =>
            {
                var connectionString = config["Redis:ConnectionString"];
                var redis = ConnectionMultiplexer.Connect(connectionString);
                var database = redis.GetDatabase(0);

                builder.RegisterGeneric(typeof(RedisAggregateCache <>)).As(typeof(IRedisAggregateCache <>)).SingleInstance();
                builder.RegisterInstance(database).AsImplementedInterfaces().SingleInstance();
            }
                       ));
        }