Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1 / SimpleRecyclingCache.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * SimpleRecyclingCache class * * Copyright (c) 1999 Microsoft Corporation */ namespace System.Web.Util { using System.Collections; /* * The purpose of this class is to provide a simple and efficient cache. * Instead of using fancy logic to expire items, it uses a simple heuristic: * when the number of entry reaches a fixed limit, the cache is reset. */ internal class SimpleRecyclingCache { private const int MAX_SIZE = 100; private static Hashtable _hashtable; internal SimpleRecyclingCache() { CreateHashtable(); } // Create or recreate the hastable private void CreateHashtable() { _hashtable = new Hashtable(MAX_SIZE, StringComparer.OrdinalIgnoreCase); } internal object this[object key] { get { return _hashtable[key]; } set { lock (this) { // The limit was reached, so reset everything if (_hashtable.Count >= MAX_SIZE) _hashtable.Clear(); _hashtable[key] = value; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * SimpleRecyclingCache class * * Copyright (c) 1999 Microsoft Corporation */ namespace System.Web.Util { using System.Collections; /* * The purpose of this class is to provide a simple and efficient cache. * Instead of using fancy logic to expire items, it uses a simple heuristic: * when the number of entry reaches a fixed limit, the cache is reset. */ internal class SimpleRecyclingCache { private const int MAX_SIZE = 100; private static Hashtable _hashtable; internal SimpleRecyclingCache() { CreateHashtable(); } // Create or recreate the hastable private void CreateHashtable() { _hashtable = new Hashtable(MAX_SIZE, StringComparer.OrdinalIgnoreCase); } internal object this[object key] { get { return _hashtable[key]; } set { lock (this) { // The limit was reached, so reset everything if (_hashtable.Count >= MAX_SIZE) _hashtable.Clear(); _hashtable[key] = value; } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlConvert.cs
- ListViewTableRow.cs
- UserControl.cs
- InfocardChannelParameter.cs
- designeractionlistschangedeventargs.cs
- SessionStateItemCollection.cs
- StrokeCollectionDefaultValueFactory.cs
- XmlSchemaAnnotated.cs
- SafeArrayTypeMismatchException.cs
- FastEncoder.cs
- FrameworkContentElement.cs
- SqlStream.cs
- HMACRIPEMD160.cs
- TreeNode.cs
- PrimitiveType.cs
- ContentDisposition.cs
- HwndTarget.cs
- SmtpNtlmAuthenticationModule.cs
- Margins.cs
- WebPartDisplayModeCancelEventArgs.cs
- StreamingContext.cs
- SqlDataSourceFilteringEventArgs.cs
- WorkflowQueue.cs
- KeyValueSerializer.cs
- XmlSchemaAttributeGroup.cs
- CollectionTraceRecord.cs
- WSSecurityJan2004.cs
- TabControl.cs
- BaseDataListActionList.cs
- _emptywebproxy.cs
- ExitEventArgs.cs
- CopyAction.cs
- PersonalizationState.cs
- ScrollContentPresenter.cs
- TextPenaltyModule.cs
- SecurityContextKeyIdentifierClause.cs
- DataGridPagerStyle.cs
- ContainerUIElement3D.cs
- DataGridViewAutoSizeModeEventArgs.cs
- SimpleApplicationHost.cs
- TextEndOfLine.cs
- DocumentPageHost.cs
- CodeCompiler.cs
- XsdBuildProvider.cs
- EventDescriptorCollection.cs
- TextRange.cs
- DifferencingCollection.cs
- ScriptControlDescriptor.cs
- IPAddressCollection.cs
- ListenerConnectionModeReader.cs
- ToolStripSettings.cs
- XamlFilter.cs
- ColumnHeaderCollectionEditor.cs
- GAC.cs
- WindowsButton.cs
- CultureSpecificCharacterBufferRange.cs
- HTMLTagNameToTypeMapper.cs
- TransformedBitmap.cs
- BooleanKeyFrameCollection.cs
- IntPtr.cs
- OracleParameterBinding.cs
- GridViewRowPresenter.cs
- StylusPointCollection.cs
- AtomMaterializerLog.cs
- LostFocusEventManager.cs
- ApplicationSecurityInfo.cs
- RequestCache.cs
- RewritingValidator.cs
- WebConfigurationManager.cs
- ReadOnlyDictionary.cs
- InheritedPropertyChangedEventArgs.cs
- PageAsyncTask.cs
- DataControlPagerLinkButton.cs
- MethodBuilder.cs
- wgx_exports.cs
- UnsafeNativeMethods.cs
- WebPartTransformerAttribute.cs
- Section.cs
- __TransparentProxy.cs
- ObjectKeyFrameCollection.cs
- ColorContext.cs
- AuthenticationServiceManager.cs
- SetIterators.cs
- AlphabetConverter.cs
- MembershipPasswordException.cs
- XmlDownloadManager.cs
- XamlTypeMapper.cs
- TextUtf8RawTextWriter.cs
- ImageListUtils.cs
- DefinitionUpdate.cs
- SecurityPermission.cs
- Repeater.cs
- TextTreeInsertUndoUnit.cs
- GreaterThan.cs
- Rfc2898DeriveBytes.cs
- LabelDesigner.cs
- TextDecoration.cs
- HtmlDocument.cs
- LassoSelectionBehavior.cs
- DataViewManagerListItemTypeDescriptor.cs