Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1305376 / 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
- EmissiveMaterial.cs
- DataSourceDesigner.cs
- XamlParser.cs
- MethodExecutor.cs
- SQLInt64.cs
- SourceSwitch.cs
- DesignerActionList.cs
- AddInDeploymentState.cs
- HideDisabledControlAdapter.cs
- ExpandSegment.cs
- PolicyImporterElementCollection.cs
- HwndTarget.cs
- SqlAliaser.cs
- Signature.cs
- GatewayIPAddressInformationCollection.cs
- SimpleBitVector32.cs
- QueryConverter.cs
- DataListDesigner.cs
- WebBrowsableAttribute.cs
- SystemColorTracker.cs
- SqlFileStream.cs
- LinkAreaEditor.cs
- HostingPreferredMapPath.cs
- TextTreeTextBlock.cs
- XmlWriterSettings.cs
- InstallHelper.cs
- DBProviderConfigurationHandler.cs
- ApplicationSecurityManager.cs
- DrawingCollection.cs
- SqlExpander.cs
- DispatchWrapper.cs
- HtmlInputRadioButton.cs
- GridViewColumnCollectionChangedEventArgs.cs
- CompModHelpers.cs
- CellRelation.cs
- EditorPartChrome.cs
- Stroke2.cs
- VirtualPathUtility.cs
- PathSegmentCollection.cs
- WebPartConnectionsConfigureVerb.cs
- LayoutSettings.cs
- GACMembershipCondition.cs
- WebServiceParameterData.cs
- BooleanFacetDescriptionElement.cs
- WindowsFormsSynchronizationContext.cs
- FusionWrap.cs
- XNodeValidator.cs
- listviewsubitemcollectioneditor.cs
- DesignerSerializationOptionsAttribute.cs
- RecognitionResult.cs
- HealthMonitoringSectionHelper.cs
- SBCSCodePageEncoding.cs
- ByteRangeDownloader.cs
- TextContainerHelper.cs
- WebPartDisplayModeCollection.cs
- ObfuscationAttribute.cs
- SqlUdtInfo.cs
- WebPageTraceListener.cs
- ParserExtension.cs
- DataControlField.cs
- NodeFunctions.cs
- TerminateSequence.cs
- dbdatarecord.cs
- HttpHeaderCollection.cs
- BindingSource.cs
- ValidatorCollection.cs
- Funcletizer.cs
- XmlCompatibilityReader.cs
- DataGridHeadersVisibilityToVisibilityConverter.cs
- KeyboardEventArgs.cs
- BitmapVisualManager.cs
- ToolStripPanelRow.cs
- Context.cs
- ParameterRetriever.cs
- SelectedGridItemChangedEvent.cs
- ParameterToken.cs
- columnmapfactory.cs
- ConfigurationElementCollection.cs
- ImageListUtils.cs
- MemberAssignment.cs
- HttpFileCollectionBase.cs
- StreamReader.cs
- CodeTypeReferenceSerializer.cs
- ImmutablePropertyDescriptorGridEntry.cs
- NativeMethods.cs
- MouseOverProperty.cs
- CheckBoxPopupAdapter.cs
- DesignerVerb.cs
- EventLogEntryCollection.cs
- TypeUtil.cs
- StreamWriter.cs
- SyntaxCheck.cs
- SHA384Cng.cs
- XsdDateTime.cs
- FileDialogPermission.cs
- DataViewListener.cs
- RegexWriter.cs
- Site.cs
- ActivationArguments.cs
- XmlTextReader.cs