public InMemoryCacheProvider( IInMemoryCaching caching, IOptions <InMemoryOptions> options) { _caching = caching; _options = options.Value; }
public static IXabarilBuilder AddXabarilInMemoryStore(this IXabarilBuilder xabarilBuilder, Action <InMemoryOptions> configure) { var options = new InMemoryOptions(); var setup = configure ?? (opts => { }); setup(options); xabarilBuilder .Services .AddMemoryCache() .AddSingleton <IFeaturesStore, InMemoryFeaturesStore>(provider => { var logger = provider.GetService <ILogger <XabarilModule> >(); var cache = provider.GetService <IMemoryCache>(); var store = new InMemoryFeaturesStore(logger, cache); if (options.FeatureConfiguration != null) { store.PersistConfiguratioAsync(options.FeatureConfiguration); } return(store); }); return(xabarilBuilder); }
/// <summary> /// Uses the in-memory provider (read config from configuration file). /// </summary> /// <param name="options">Options.</param> /// <param name="configuration">The configuration.</param> /// <param name="name">The name of this provider instance.</param> /// <param name="sectionName">The section name in the configuration file.</param> public static EasyCachingOptions UseInMemory( this EasyCachingOptions options , IConfiguration configuration , string name = EasyCachingConstValue.DefaultInMemoryName , string sectionName = EasyCachingConstValue.InMemorySection ) { var dbConfig = configuration.GetSection(sectionName); var memoryOptions = new InMemoryOptions(); dbConfig.Bind(memoryOptions); void configure(InMemoryOptions x) { x.EnableLogging = memoryOptions.EnableLogging; x.MaxRdSecond = memoryOptions.MaxRdSecond; x.LockMs = memoryOptions.LockMs; x.SleepMs = memoryOptions.SleepMs; x.SerializerName = memoryOptions.SerializerName; x.CacheNulls = memoryOptions.CacheNulls; x.DBConfig = memoryOptions.DBConfig; } return(options.UseInMemory(configure, name)); }
public void Dto_with_no_properties_causes_null_exception() { using (var context = new SomeContext(InMemoryOptions.Create <SomeContext>())) { //ATTEMPT var ex = Assert.Throws <InvalidOperationException>(() => context.SetupSingleDtoAndEntities <ImutableDto>()); //VERIFY ex.Message.ShouldEqual("The ImutableDto class inherits ILinkToEntity<T> but has no properties in it!"); } }
public void Dto_with_no_properties_causes_null_exception() { using (var context = new SomeContext(InMemoryOptions.Create <SomeContext>())) { //ATTEMPT var ex = Assert.Throws <InvalidOperationException>(() => context.SetupSingleDtoAndEntities <ImutableDto>()); //VERIFY ex.Message.ShouldEqual("A DTO using the ILinkToEntity<T> must contain at least one Property!"); } }
public static IServiceCollection UseInMemoryCache( this IServiceCollection services, IConfiguration configuration) { var options = new InMemoryOptions(); configuration.GetSection("CacheOptions:InMemoryOptions").Bind(options); services.Configure <InMemoryOptions>(configuration.GetSection("CacheOptions:InMemoryOptions")); services.AddSingleton <IInMemoryCaching, InMemoryCaching>(); services.AddSingleton <ICacheProvider, InMemoryCacheProvider>(); return(services); }
// To run this example, run the following command from // the reporoot\examples\Console\. // (eg: C:\repos\opentelemetry-dotnet\examples\Console\) // // dotnet run inmemory internal static object Run(InMemoryOptions options) { // List that will be populated with the traces by InMemoryExporter var exportedItems = new List <Activity>(); RunWithActivitySource(exportedItems); // List exportedItems is populated with the Activity objects logged by TracerProvider foreach (var activity in exportedItems) { System.Console.WriteLine($"ActivitySource: {activity.Source.Name} logged the activity {activity.DisplayName}"); } return(null); }
/// <summary> /// Uses the in-memory provider. /// </summary> /// <param name="options">Options.</param> /// <param name="name">The name of this provider instance.</param> public static EasyCachingOptions UseInMemory( this EasyCachingOptions options , string name = EasyCachingConstValue.DefaultInMemoryName ) { var option = new InMemoryOptions(); void configure(InMemoryOptions x) { x.EnableLogging = option.EnableLogging; x.MaxRdSecond = option.MaxRdSecond; x.DBConfig = option.DBConfig; } return(options.UseInMemory(configure, name)); }
public TestCachingProvider(string name, IEnumerable <IInMemoryCaching> cache, InMemoryOptions options, IDistributedLockFactory factory, ILoggerFactory loggerFactory = null) : base(name, cache, options, factory, loggerFactory) { }