/// <inheritdoc />
        public ICache BuildCache(string regionName, IDictionary <string, string> properties)
        {
            if (CacheFactory == null)
            {
                throw new InvalidOperationException(
                          $"{nameof(CacheFactory)} is null, cannot build a distributed cache without a cache factory. " +
                          $"Please provide coredistributedcache configuration section with a factory-class attribute or set" +
                          $"{nameof(CacheFactory)} before building a session factory.");
            }

            if (regionName == null)
            {
                regionName = string.Empty;
            }

            if (ConfiguredCachesProperties.TryGetValue(regionName, out var configuredProperties) && configuredProperties.Count > 0)
            {
                if (properties != null)
                {
                    // Duplicate it for not altering the global configuration
                    properties = new Dictionary <string, string>(properties);
                    foreach (var prop in configuredProperties)
                    {
                        properties[prop.Key] = prop.Value;
                    }
                }
                else
                {
                    properties = configuredProperties;
                }
            }

            // create cache
            if (properties == null)
            {
                properties = new Dictionary <string, string>(1);
            }

            if (Log.IsDebugEnabled())
            {
                var sb = new StringBuilder();

                foreach (var de in properties)
                {
                    sb.Append("name=");
                    sb.Append(de.Key);
                    sb.Append("&value=");
                    sb.Append(de.Value);
                    sb.Append(";");
                }

                Log.Debug("building cache with region: {0}, properties: {1}, factory: {2}", regionName, sb.ToString(), CacheFactory.GetType().FullName);
            }
            return
                (new CoreDistributedCache(CacheFactory.BuildCache(), CacheFactory.Constraints, regionName, properties)
            {
                AppendHashcodeToKey = AppendHashcodeToKey
            });
        }