Example #1
0
        public RedisCacheOptions(ICachingConfiguration startupConfiguration)
        {
            StartupConfiguration = startupConfiguration;

            ConnectionString = GetDefaultConnectionString();
            DatabaseId       = GetDefaultDatabaseId();
        }
Example #2
0
        protected override void Arrange()
        {
            ConfigurationSourceBuilder = new ConfigurationSourceBuilder();

            CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching();

            ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName);
        }
        /// <summary>
        /// Creates an instance of <see cref="CacheManagerSettingsExtension"/> passing the caching configuration's fluent interface builder.
        /// </summary>
        /// <param name="context">The current caching configuration's fluent interface builder.<br/>
        /// This interface must implement <see cref="ICachingConfigurationExtension"/>.</param>
        public CacheManagerSettingsExtension(ICachingConfiguration context)
        {
            extensionContext = context as ICachingConfigurationExtension;

            if (extensionContext == null) throw new ArgumentException(
                String.Format(CultureInfo.CurrentCulture, Resources.ExceptionParameterMustImplement, typeof(ICachingConfigurationExtension)),
                "context");
        }
        protected override void Arrange()
        {
            ConfigurationSourceBuilder = new ConfigurationSourceBuilder();

            CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching();

            ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName);
        }
Example #5
0
        /// <summary>
        /// Configures caching to use Redis as cache server.
        /// </summary>
        /// <param name="cachingConfiguration">The caching configuration.</param>
        /// <param name="optionsAction">Ac action to get/set options</param>
        public static void UseRedis(this ICachingConfiguration cachingConfiguration, Action <CodeZeroRedisCacheOptions> optionsAction)
        {
            var iocManager = cachingConfiguration.CodeZeroConfiguration.IocManager;

            iocManager.RegisterIfNot <ICacheManager, CodeZeroRedisCacheManager>();

            optionsAction(iocManager.Resolve <CodeZeroRedisCacheOptions>());
        }
 public void Initialize()
 {
     Modules                = Resolver.Resolve <IModuleConfigurations>();
     BackgroundJobs         = Resolver.Resolve <IBackgroundJobConfiguration>();
     UnitOfWork             = Resolver.Resolve <IUnitOfWorkDefaultOptions>();
     Caching                = Resolver.Resolve <ICachingConfiguration>();
     TypedConnectionStrings = new Dictionary <Type, string>();
 }
Example #7
0
        /// <summary>
        /// Adds a new <see cref="CacheManager"/> to the caching configuration.
        /// </summary>
        /// <param name="context">Fluent interface extension point.</param>
        /// <param name="cacheManagerName">The name of the <see cref="CacheManager"/>.</param>
        /// <returns>Fluent interface that can be used to further configure the created <see cref="CacheManagerData"/>. </returns>
        /// <seealso cref="CacheManager"/>
        /// <seealso cref="CacheManagerData"/>
        public static ICachingConfigurationCacheManager ForCacheManagerNamed(this ICachingConfiguration context, string cacheManagerName)
        {
            if (string.IsNullOrEmpty(cacheManagerName))
            {
                throw new ArgumentException(Resources.EmptyParameterName, "cacheManagerName");
            }

            return(new ForCacheManagerNamedBuilder(context, cacheManagerName));
        }
Example #8
0
        /// <summary>
        ///     Configures caching to use Redis as cache server.
        /// </summary>
        /// <param name="cachingConfiguration">The caching configuration.</param>
        /// <param name="optionsAction">Ac action to get/set options</param>
        public static void UseCSRedis(this ICachingConfiguration cachingConfiguration,
                                      Action <AbpRedisCacheOptions> optionsAction)
        {
            var iocManager = cachingConfiguration.AbpConfiguration.IocManager;

            iocManager.RegisterIfNot <ICacheManager, AbpRedisCacheManager>();

            optionsAction(iocManager.Resolve <AbpRedisCacheOptions>());
        }
            public ForCacheManagerNamedBuilder(ICachingConfiguration context, string cacheManagerName)
                : base(context)
            {
                cacheManagerData = new CacheManagerData
                {
                    Name = cacheManagerName
                };

                base.CachingSettings.CacheManagers.Add(cacheManagerData);
            }
        protected override void Arrange()
        {
            ConfigurationSourceBuilder = new ConfigurationSourceBuilder();

            CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching();

            ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName);

            EncryptUsing = ConfigureCacheManager.StoreInIsolatedStorage(cacheManagerStoreName).EncryptUsing;
        }
        protected override void Arrange()
        {
            ConfigurationSourceBuilder = new ConfigurationSourceBuilder();

            CachingConfiguration = ConfigurationSourceBuilder.ConfigureCaching();

            ConfigureCacheManager = CachingConfiguration.ForCacheManagerNamed(cacheManagerName);

            EncryptUsing = ConfigureCacheManager.StoreInIsolatedStorage(cacheManagerStoreName).EncryptUsing;
        }
Example #12
0
            public ForCacheManagerNamedBuilder(ICachingConfiguration context, string cacheManagerName)
                : base(context)
            {
                cacheManagerData = new CacheManagerData
                {
                    Name = cacheManagerName
                };

                base.CachingSettings.CacheManagers.Add(cacheManagerData);
            }
        /// <summary>
        /// Creates an instance of <see cref="CacheManagerSettingsExtension"/> passing the caching configuration's fluent interface builder.
        /// </summary>
        /// <param name="context">The current caching configuration's fluent interface builder.<br/>
        /// This interface must implement <see cref="ICachingConfigurationExtension"/>.</param>
        public CacheManagerSettingsExtension(ICachingConfiguration context)
        {
            extensionContext = context as ICachingConfigurationExtension;

            if (extensionContext == null)
            {
                throw new ArgumentException(
                          String.Format(CultureInfo.CurrentCulture, Resources.ExceptionParameterMustImplement, typeof(ICachingConfigurationExtension)),
                          "context");
            }
        }
Example #14
0
        public void GetConfigurationAssemblyPath_TestDecoratedWithAssemblyFile_AllowsAccessToConfigurationValuesFromCustomConfiguration()
        {
            string assemblyPath = ExternalConfiguration.GetConfigurationAssemblyPath(MethodBase.GetCurrentMethod());

            ICachingConfiguration subject = null;

            Assert.That(() => subject = new CachingConfiguration(assemblyPath), Throws.Nothing);

            Assert.That(subject.TimeToExpire("expiration1"), Is.EqualTo(1.Seconds()));
            Assert.That(subject.HasDependencies("cache2"), Is.True);
            Assert.That(subject.GetDependantCaches("cache1"), Is.EqualTo(new[] { "cache1_1", "cache1_2" }));
        }
Example #15
0
            public ForCustomCacheManagerNamedBuilder(ICachingConfiguration context, string cacheManagerName, Type customCacheManagerType, NameValueCollection attributes)
                : base(context)
            {
                cacheManagerData = new CustomCacheManagerData
                {
                    Name = cacheManagerName,
                    Type = customCacheManagerType
                };

                cacheManagerData.Attributes.Add(attributes);

                base.CachingSettings.CacheManagers.Add(cacheManagerData);
            }
    /// <summary>
    /// Configures caching to use Redis as cache server.
    /// </summary>
    /// <param name="cachingConfiguration">The caching configuration.</param>
    /// <param name="optionsAction">Action to get/set options</param>
    /// <param name="usePerRequestRedisCache">Replaces ICacheManager with <see cref="Abp.Runtime.Caching.Redis.AbpPerRequestRedisCacheManager"/></param>
    public static void UseRedis(this ICachingConfiguration cachingConfiguration, Action <AbpRedisCacheOptions> optionsAction, bool usePerRequestRedisCache)
    {
        if (!usePerRequestRedisCache)
        {
            cachingConfiguration.UseRedis(optionsAction);
            return;
        }

        var iocManager = cachingConfiguration.AbpConfiguration.IocManager;

        iocManager.RegisterIfNot <ICacheManager, AbpPerRequestRedisCacheManagerForReplacement>();

        optionsAction(iocManager.Resolve <AbpRedisCacheOptions>());
    }
Example #17
0
        public CachingQueryDispatcher(ICachingConfiguration cachingConfiguration, IQueryDispatcher queryDispatcher)
        {
            if (cachingConfiguration == null)
            {
                throw new ArgumentNullException(nameof(cachingConfiguration));
            }

            if (queryDispatcher == null)
            {
                throw new ArgumentNullException(nameof(queryDispatcher));
            }

            this.cachingConfiguration = cachingConfiguration;
            this.queryDispatcher      = queryDispatcher;
        }
Example #18
0
        /// <summary>
        ///     Configures caching to use Redis as cache server.
        /// </summary>
        /// <param name="cachingConfiguration">The caching configuration.</param>
        /// <param name="optionsAction">Ac action to get/set options</param>
        public static void UseCSRedis(this ICachingConfiguration cachingConfiguration,
                                      Action <AbpRedisCacheOptions> optionsAction)
        {
            var iocManager = cachingConfiguration.AbpConfiguration.IocManager;

            iocManager.RegisterIfNot <ICacheManager, AbpRedisCacheManager>();

            var options = iocManager.Resolve <AbpRedisCacheOptions>();

            optionsAction(options);

            var connectionString = options.ConnectionString;

            if (options.DatabaseId > -1)
            {
                connectionString = options.ConnectionString.TrimEnd(';') + ",defaultDatabase=" + options.DatabaseId;
            }
            RedisHelper.Initialization(new CSRedisClient(connectionString));
        }
Example #19
0
        public Caching(ICachingConfiguration configuration, string encryptionKey)
        {
            _config        = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _encryptionKey = encryptionKey;

            if (_config.EnableEncryption)
            {
                if (string.IsNullOrEmpty(encryptionKey))
                {
                    throw new ArgumentNullException(nameof(encryptionKey),
                                                    "When EnableEncryption is enabled, an encryptionKey is required when initializing the Caching.");
                }
                _encryptionKey = encryptionKey;
            }

            if (_config.AutoLoad)
            {
                Load();
            }
        }
Example #20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public AbpMemoryCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
 }
 public DefaultRedisCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
     IocManager.RegisterIfNot<RedisCache>(DependencyLifeStyle.Multiple);
 }
Example #22
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="iocManager"></param>
 /// <param name="configuration"></param>
 protected CacheManagerBase(IIocManager iocManager, ICachingConfiguration configuration)
 {
     IocManager    = iocManager;
     Configuration = configuration;
     Caches        = new ConcurrentDictionary <string, ICache>();
 }
 public InMemoryCacheManager(IIocManager iocManager, ICachingConfiguration configuration) : base(iocManager, configuration)
 {
     IocManager.RegisterIfAbsent<InMemoryCache>(DependencyLifeStyle.Transient);
 }
Example #24
0
 /// <summary>
 /// Configures caching to use Redis as cache server.
 /// </summary>
 /// <param name="cachingConfiguration">The caching configuration.</param>
 public static void UseRedis(this ICachingConfiguration cachingConfiguration)
 {
     cachingConfiguration.UseRedis(options => { });
 }
        protected override void Arrange()
        {
            base.Arrange();

            CachingConfiguration = base.ConfigurationSourceBuilder.ConfigureCaching();
        }
 /// <summary>
 /// Configures caching to use Redis as cache server.
 /// </summary>
 /// <param name="cachingConfiguration">The caching configuration.</param>
 /// <param name="usePerRequestRedisCache">Replaces ICacheManager with <see cref="Abp.Runtime.Caching.Redis.AbpPerRequestRedisCacheManager"/></param>
 public static void UseRedis(this ICachingConfiguration cachingConfiguration, bool usePerRequestRedisCache)
 {
     cachingConfiguration.UseRedis(options => { }, usePerRequestRedisCache);
 }
 /// <summary>
 ///     Constructor.
 /// </summary>
 public StoveMemoryCacheManager(IScopeResolver scopeResolver, ICachingConfiguration configuration)
     : base(scopeResolver.BeginScope(), configuration)
 {
 }
 public RedisCacheManager(ICachingConfiguration configuration, IRedisCacheDatabaseProvider redisCacheDatabaseProvider, IRedisCacheSerializer redisCacheSerializer) : base(configuration)
 {
     RedisCacheDatabaseProvider = redisCacheDatabaseProvider;
     RedisCacheSerializer       = redisCacheSerializer;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeZeroRedisCacheManager"/> class.
 /// </summary>
 public CodeZeroRedisCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
     IocManager.RegisterIfNot <CodeZeroRedisCache>(DependencyLifeStyle.Transient);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 public AbpMemoryCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
     Logger = NullLogger.Instance;
 }
 public DotnetMemoryCacheManager(ICachingConfiguration configuration) : base(configuration)
 {
 }
Example #32
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="iocManager"></param>
 /// <param name="configuration"></param>
 protected CacheManagerBase(IIocManager iocManager, ICachingConfiguration configuration)
 {
     IocManager = iocManager;
     Configuration = configuration;
     Caches = new ConcurrentDictionary<string, ICache>();
 }
Example #33
0
 /// <summary>
 /// Adds a custom cache mananger of type <typeparamref name="TCustomCacheManager"/> to the caching configuration.<br/>
 /// Specifying additional conifguration attributes.
 /// </summary>
 /// <typeparam name="TCustomCacheManager">The concrete type of the custom cache manager.</typeparam>
 /// <param name="context">Fluent interface extension point.</param>
 /// <param name="cacheManagerName">The name of the cache manager that should be added to configuration.</param>
 /// <param name="attributes">Attributes that should be passed to <typeparamref name="TCustomCacheManager"/> when creating an instance.</param>
 /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomCacheManagerData"/>. </returns>
 /// <seealso cref="CustomCacheManagerData"/>
 public static ICachingConfigurationCustomCacheManager ForCustomCacheManagerNamed <TCustomCacheManager>(this ICachingConfiguration context, string cacheManagerName, NameValueCollection attributes)
     where TCustomCacheManager : ICacheManager
 {
     return(ForCustomCacheManagerNamed(context, cacheManagerName, typeof(TCustomCacheManager), attributes));
 }
Example #34
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public AbpMemoryCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
     IocManager.RegisterIfNot <AbpMemoryCache>(DependencyLifeStyle.Transient);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbpRedisCacheManager"/> class.
 /// 初始化一个新的<see cref="AbpRedisCacheManager"/>类
 /// </summary>
 /// <param name="iocManager">Ioc管理类</param>
 /// <param name="configuration">缓存配置类</param>
 public AbpRedisCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
     : base(iocManager, configuration)
 {
     IocManager.RegisterIfNot<AbpRedisCache>(DependencyLifeStyle.Transient);
 }
Example #36
0
 /// <summary>
 /// Adds a custom cache mananger of type <paramref name="customCacheManagerType"/> to the caching configuration.
 /// </summary>
 /// <param name="context">Fluent interface extension point.</param>
 /// <param name="cacheManagerName">The name of the cache manager that should be added to configuration.</param>
 /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomCacheManagerData"/>. </returns>
 /// <param name="customCacheManagerType">The concrete type of the custom cache manager. This type must implement <see cref="ICacheManager"/>.</param>
 /// <seealso cref="CustomCacheManagerData"/>
 public static ICachingConfigurationCustomCacheManager ForCustomCacheManagerNamed(this ICachingConfiguration context, string cacheManagerName, Type customCacheManagerType)
 {
     return(ForCustomCacheManagerNamed(context, cacheManagerName, customCacheManagerType, new NameValueCollection()));
 }
Example #37
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="configuration"></param>
 protected CacheManagerBase(ICachingConfiguration configuration)
 {
     Configuration = configuration;
     Caches        = new ConcurrentDictionary <string, TCache>();
 }
Example #38
0
        /// <summary>
        /// Adds a custom cache mananger of type <paramref name="customCacheManagerType"/> to the caching configuration.<br/>
        /// Specifying additional conifguration attributes.
        /// </summary>
        /// <param name="context">Fluent interface extension point.</param>
        /// <param name="cacheManagerName">The name of the cache manager that should be added to configuration.</param>
        /// <param name="customCacheManagerType">The concrete type of the custom cache manager. This type must implement <see cref="ICacheManager"/>.</param>
        /// <param name="attributes">Attributes that should be passed to <paramref name="customCacheManagerType"/> when creating an instance.</param>
        /// <returns>Fluent interface that can be used to further configure the created <see cref="CustomCacheManagerData"/>. </returns>
        /// <seealso cref="CustomCacheManagerData"/>
        public static ICachingConfigurationCustomCacheManager ForCustomCacheManagerNamed(this ICachingConfiguration context, string cacheManagerName, Type customCacheManagerType, NameValueCollection attributes)
        {
            if (string.IsNullOrEmpty(cacheManagerName))
            {
                throw new ArgumentException(Resources.EmptyParameterName);
            }
            if (customCacheManagerType == null)
            {
                throw new ArgumentNullException("customCacheManagerType");
            }
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            return(new ForCustomCacheManagerNamedBuilder(context, cacheManagerName, customCacheManagerType, attributes));
        }
Example #39
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="StoveRedisCacheManager" /> class.
 /// </summary>
 public StoveRedisCacheManager([NotNull] IScopeResolver scopeResolver, [NotNull] ICachingConfiguration configuration)
     : base(scopeResolver.BeginScope(), configuration)
 {
 }