123456789101112131415161718192021222324252627 |
- using Microsoft.Extensions.DependencyInjection;
- namespace GxPress.Api.ServiceExtensions
- {
- public static class CachingExtension
- {
- public static IServiceCollection AddDistributedCache(this IServiceCollection services, string cacheConnectionString)
- {
- var isSettings = false;
- if (!string.IsNullOrEmpty(cacheConnectionString))
- {
- isSettings = true;
- services.AddStackExchangeRedisCache(options =>
- {
- options.Configuration = cacheConnectionString;
- options.InstanceName = "";
- });
- }
- if (!isSettings)
- {
- services.AddDistributedMemoryCache();
- }
- return services;
- }
- }
- }
|