コード例 #1
0
        /// <summary>
        /// Function to initialize the provider
        /// </summary>
        /// <param name="name">Name of the element in the configuration file</param>
        /// <param name="config">Configuration values for the provider from the Web.config file</param>
        public override void Initialize(
            string name,
            NameValueCollection config)
        {
            // Initialize the base class
            base.Initialize(name, config);

            // Create our Couchbase bucket instance
            _bucket = ProviderHelper.GetBucket(name, config);

            // By default use exclusive session access. But allow it to be overridden in the config file
            var exclusive = ProviderHelper.GetAndRemove(config, "exclusiveAccess", false) ?? "true";

            _exclusiveAccess = (string.Compare(exclusive, "true", StringComparison.OrdinalIgnoreCase) == 0);

            // Allow optional header and data prefixes to be used for this application
            var headerPrefix = ProviderHelper.GetAndRemove(config, "headerPrefix", false);

            if (headerPrefix != null)
            {
                _headerPrefix = headerPrefix;
            }
            var dataPrefix = ProviderHelper.GetAndRemove(config, "dataPrefix", false);

            if (dataPrefix != null)
            {
                _dataPrefix = dataPrefix;
            }

            // Make sure no extra attributes are included
            ProviderHelper.CheckForUnknownAttributes(config);
        }
コード例 #2
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            // Initialize the base class
            base.Initialize(name, config);

            // Create our Couchbase client instance
            _client = ProviderHelper.GetClient(name, config, () => (ICouchbaseClientFactory) new CouchbaseClientFactory(), out _disposeClient);

            if (_isFirstTimeInitialization)
            {
                lock (FirstTimeInitializationSync)
                {
                    if (_isFirstTimeInitialization)
                    {
                        var loggingEnabled = ProviderHelper.GetAndRemove(config, "logging", false) ?? "false";
                        _isLoggingEnabled = (String.Compare(loggingEnabled, "true", StringComparison.OrdinalIgnoreCase) == 0);

                        if (_isLoggingEnabled)
                        {
                            // Path where to store NLog logs (effective if useExistedLoggingConfig != "true")
                            var loggingFileName = ProviderHelper.GetAndRemove(config, "loggingFilename", false) ?? "Logs/CouchbaseSessionStateProvider.log";

                            // useExistedLoggingConfig = "true" to use existed application NLog config file
                            // or useExistedLoggingConfig = "false" (or just skip this config) to configure NLog in Couchbase provider and override application settings (if exists)
                            var useExistedLoggingConfigString = ProviderHelper.GetAndRemove(config, "useExistedLoggingConfig", false) ?? "false";
                            var useExistedLoggingConfig       = (String.Compare(useExistedLoggingConfigString, "true", StringComparison.OrdinalIgnoreCase) == 0);

                            _logger = SetupLogger(useExistedLoggingConfig, loggingFileName);
                        }

                        // By default use exclusive session access. But allow it to be overridden in the config file
                        var exclusive = ProviderHelper.GetAndRemove(config, "exclusiveAccess", false) ?? "true";
                        _exclusiveAccess = (String.Compare(exclusive, "true", StringComparison.OrdinalIgnoreCase) == 0);

                        // By default do not use compression on session data
                        var compress = ProviderHelper.GetAndRemove(config, "compress", false) ?? "false";
                        _compressData = (String.Compare(compress, "true", StringComparison.OrdinalIgnoreCase) == 0);

                        if (_compressData)
                        {
                            // By default we use lz4 instead of gzip, because it is considered much faster!
                            var compressionTypeString = ProviderHelper.GetAndRemove(config, "compressionType", false) ?? "quicklz";
                            _compressor = CompressorFactory.Create(compressionTypeString);
                        }

                        LogProviderConfiguration();

                        // Make sure no extra attributes are included
                        ProviderHelper.CheckForUnknownAttributes(config);

                        _isFirstTimeInitialization = false;
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Function to initialize the provider
        /// </summary>
        /// <param name="name">Name of the element in the configuration file</param>
        /// <param name="config">Configuration values for the provider from the Web.config file</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize the base class
            base.Initialize(name, config);

            lock (_syncObj)
            {
                if (_cluster == null)
                {
                    // Create our Cluster based off the CouchbaseConfigSection
                    _cluster = ProviderHelper.GetCluster(name, config);
                }
                if (_bucket == null)
                {
                    // Create the bucket based off the name provided in the
                    _bucket = ProviderHelper.GetBucket(name, config, _cluster);
                }
                else
                {
                    ProviderHelper.GetAndRemove(config, "bucket", false);
                }
            }
            // By default use exclusive session access. But allow it to be overridden in the config file
            var exclusive = ProviderHelper.GetAndRemove(config, "exclusiveAccess", false) ?? "true";

            _exclusiveAccess = (string.Compare(exclusive, "true", StringComparison.OrdinalIgnoreCase) == 0);

            // Allow optional header and data prefixes to be used for this application
            var headerPrefix = ProviderHelper.GetAndRemove(config, "headerPrefix", false);

            if (headerPrefix != null)
            {
                HeaderPrefix = headerPrefix;
            }
            var dataPrefix = ProviderHelper.GetAndRemove(config, "dataPrefix", false);

            if (dataPrefix != null)
            {
                DataPrefix = dataPrefix;
            }
            var maxRetryCount = ProviderHelper.GetAndRemove(config, "maxRetryCount", false);
            var temp          = 0;

            if (int.TryParse(maxRetryCount, out temp))
            {
                _maxRetryCount = temp;
            }

            // Make sure no extra attributes are included
            ProviderHelper.CheckForUnknownAttributes(config);
        }
コード例 #4
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            // Initialize the base class
            base.Initialize(name, config);

            // Create our Couchbase client instance
            client = ProviderHelper.GetClient(name, config, () => (ICouchbaseClientFactory) new CouchbaseClientFactory(), out disposeClient);

            // By default use exclusive session access. But allow it to be overridden in the config file
            var exclusive = ProviderHelper.GetAndRemove(config, "exclusiveAccess", false) ?? "true";

            exclusiveAccess = (String.Compare(exclusive, "true", true) == 0);

            // Make sure no extra attributes are included
            ProviderHelper.CheckForUnknownAttributes(config);
        }
コード例 #5
0
        /// <summary>
        /// Function to initialize the provider
        /// </summary>
        /// <param name="name">Name of the element in the configuration file</param>
        /// <param name="config">Configuration values for the provider from the Web.config file</param>
        public override void Initialize(
            string name,
            NameValueCollection config)
        {
            // Initialize the base class
            base.Initialize(name, config);

            // Create our Couchbase bucket instance
            _bucket = ProviderHelper.GetBucket(name, config);

            // Allow optional prefix to be used for this application
            var prefix = ProviderHelper.GetAndRemove(config, "prefix", false);

            if (prefix != null)
            {
                _prefix = prefix;
            }

            // Make sure no extra attributes are included
            ProviderHelper.CheckForUnknownAttributes(config);
        }