Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 4 / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QilPatternFactory.cs
- ReadWriteObjectLock.cs
- EntityParameterCollection.cs
- GuidTagList.cs
- LogLogRecordEnumerator.cs
- WindowsPrincipal.cs
- URLEditor.cs
- PackWebRequest.cs
- Int16KeyFrameCollection.cs
- MsiStyleLogWriter.cs
- Transform3DGroup.cs
- FilterableAttribute.cs
- TextContainerChangedEventArgs.cs
- XmlWellformedWriter.cs
- ReferenceEqualityComparer.cs
- TrackBar.cs
- _TransmitFileOverlappedAsyncResult.cs
- ContextMenuStrip.cs
- EditorZoneDesigner.cs
- PropertyTabChangedEvent.cs
- PolicyLevel.cs
- Translator.cs
- DynamicDocumentPaginator.cs
- ControlBuilderAttribute.cs
- CapiNative.cs
- Module.cs
- httpserverutility.cs
- ClaimComparer.cs
- iisPickupDirectory.cs
- HttpModuleAction.cs
- DbConnectionPoolGroupProviderInfo.cs
- TriggerActionCollection.cs
- EnumerableCollectionView.cs
- CheckedListBox.cs
- OuterGlowBitmapEffect.cs
- SqlCrossApplyToCrossJoin.cs
- PerformanceCounterPermission.cs
- HScrollBar.cs
- SingleKeyFrameCollection.cs
- ConfigurationSection.cs
- EventLogPermissionAttribute.cs
- XmlSchemaCollection.cs
- PerspectiveCamera.cs
- IsolatedStorage.cs
- XmlNodeWriter.cs
- DataGridViewComboBoxColumn.cs
- SoapCodeExporter.cs
- BamlStream.cs
- ApplicationException.cs
- IntranetCredentialPolicy.cs
- FileDialog_Vista.cs
- QilXmlReader.cs
- LeaseManager.cs
- ImportedNamespaceContextItem.cs
- DSACryptoServiceProvider.cs
- ComponentManagerBroker.cs
- TerminatorSinks.cs
- InvalidOperationException.cs
- PageThemeCodeDomTreeGenerator.cs
- CodeMemberField.cs
- TCEAdapterGenerator.cs
- Underline.cs
- DataFieldCollectionEditor.cs
- HttpDateParse.cs
- TokenBasedSet.cs
- XhtmlTextWriter.cs
- ConvertEvent.cs
- SerializeAbsoluteContext.cs
- ThicknessAnimationBase.cs
- InvalidTimeZoneException.cs
- WinFormsSpinner.cs
- WebConfigurationHostFileChange.cs
- EventWaitHandle.cs
- UnaryExpressionHelper.cs
- DBDataPermissionAttribute.cs
- WizardPanel.cs
- LogReserveAndAppendState.cs
- LambdaCompiler.ControlFlow.cs
- ListenerElementsCollection.cs
- ProjectedWrapper.cs
- DataGridViewSelectedCellCollection.cs
- GenericRootAutomationPeer.cs
- HTMLTagNameToTypeMapper.cs
- JsonWriterDelegator.cs
- Int32CollectionConverter.cs
- ImageDrawing.cs
- OdbcParameterCollection.cs
- FullTrustAssemblyCollection.cs
- CursorInteropHelper.cs
- ToolboxDataAttribute.cs
- DataSourceXmlSerializer.cs
- ProfilePropertyNameValidator.cs
- BufferedWebEventProvider.cs
- MergeFilterQuery.cs
- MsmqOutputMessage.cs
- ToggleProviderWrapper.cs
- DataGridTextColumn.cs
- ZipIOExtraFieldZip64Element.cs
- WebPartZone.cs
- RefreshEventArgs.cs