Beispiel #1
0
        public MongoDbContext(DistributedCacheMongoModuleConfiguration configuration)
        {
            _configuration = configuration;
            var url = MongoUrl.Create(configuration.ConnectionString);

            MongoClient = new MongoClient(url);
            Db          = MongoClient?.GetDatabase(url.DatabaseName);
        }
Beispiel #2
0
 /// <summary>
 ///     Add MongoDB Distributed Cache
 /// </summary>
 public static IServiceCollection AddMongoDistributedCache(this IServiceCollection services,
                                                           DistributedCacheMongoModuleConfiguration configuration)
 {
     BsonClassMap.RegisterClassMap(new CacheEntryMap());
     return(services
            .AddSingleton(configuration)
            .AddSingleton <MongoDbContext>()
            .AddSingleton <IDistributedCache, MongoDbCache>());
 }