コード例 #1
0
        /// <summary>
        /// Newly created caches do not have a MemoryStore or a DiskStore.
        ///
        /// This method creates those and makes the cache ready to accept elements.
        /// </summary>
        internal void Init()
        {
            lock (this) {
                if (_configuration.MaxElementsInMemory == 0)
                {
                    _configuration.MaxElementsInMemory = 1;
                    if (_log.IsWarnEnabled)
                    {
                        _log.Warn(string.Format(
                                      CultureInfo.InvariantCulture,
                                      SR.WarnZeroMemoryStoreSize,
                                      _configuration.Name));
                    }
                }

                _diskStore   = this.CreateDiskStore();
                _memoryStore = MemoryStore.Create(this, _diskStore);
                this.ChangeStatus(Status.Alive);
            }

            if (_log.IsDebugEnabled)
            {
                _log.Debug("Initialised cache: " + _configuration.Name);
            }
        }