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
- XmlName.cs
- VectorKeyFrameCollection.cs
- SqlBooleanMismatchVisitor.cs
- SelectedDatesCollection.cs
- SystemGatewayIPAddressInformation.cs
- DomainConstraint.cs
- ParserHooks.cs
- BindingWorker.cs
- SimpleMailWebEventProvider.cs
- ValidatorAttribute.cs
- XamlTypeMapperSchemaContext.cs
- EdmToObjectNamespaceMap.cs
- HtmlGenericControl.cs
- SparseMemoryStream.cs
- DocumentViewerHelper.cs
- FamilyCollection.cs
- LinqDataSourceDisposeEventArgs.cs
- WebPartVerb.cs
- ObjectContext.cs
- CompositeActivityDesigner.cs
- PointKeyFrameCollection.cs
- ExclusiveCanonicalizationTransform.cs
- ReadOnlyPermissionSet.cs
- MultiDataTrigger.cs
- TcpClientChannel.cs
- SendActivityDesigner.cs
- TdsParameterSetter.cs
- ObjectSet.cs
- InternalEnumValidatorAttribute.cs
- CheckBox.cs
- DataServiceHostWrapper.cs
- HttpStreamMessage.cs
- TrackBar.cs
- DescendantOverDescendantQuery.cs
- InkSerializer.cs
- ListViewDataItem.cs
- XhtmlTextWriter.cs
- AvTraceDetails.cs
- DataColumnMappingCollection.cs
- CompositionCommandSet.cs
- LoginCancelEventArgs.cs
- KeyConstraint.cs
- ProcessThreadCollection.cs
- SafeNativeMethodsCLR.cs
- DocumentViewerHelper.cs
- dtdvalidator.cs
- BitmapEffectDrawingContextState.cs
- ConvertBinder.cs
- XamlWriter.cs
- EqualityComparer.cs
- ToolStripSettings.cs
- SecurityHelper.cs
- DataViewSettingCollection.cs
- CheckableControlBaseAdapter.cs
- behaviorssection.cs
- FunctionParameter.cs
- MobileUserControl.cs
- AbsoluteQuery.cs
- AndAlso.cs
- DmlSqlGenerator.cs
- RulePatternOps.cs
- TextTreeText.cs
- XmlCharType.cs
- rsa.cs
- TrackBar.cs
- SetterTriggerConditionValueConverter.cs
- ProjectionNode.cs
- TypeInitializationException.cs
- LayoutTableCell.cs
- DefaultTextStoreTextComposition.cs
- TextBoxAutomationPeer.cs
- FactoryGenerator.cs
- SoapElementAttribute.cs
- EntitySet.cs
- assemblycache.cs
- LabelInfo.cs
- InheritanceAttribute.cs
- RequestQueue.cs
- XmlIncludeAttribute.cs
- ScriptIgnoreAttribute.cs
- ExceptionValidationRule.cs
- ListViewItemEventArgs.cs
- HttpConfigurationSystem.cs
- HttpValueCollection.cs
- RC2.cs
- Vector3DKeyFrameCollection.cs
- DesignerCatalogPartChrome.cs
- ToolStripPanelCell.cs
- NetworkInformationPermission.cs
- StateRuntime.cs
- AssemblyCacheEntry.cs
- XamlSerializer.cs
- ApplicationActivator.cs
- XamlFigureLengthSerializer.cs
- MethodToken.cs
- Aggregates.cs
- _HeaderInfo.cs
- ReferentialConstraint.cs
- CodeDefaultValueExpression.cs
- CanExecuteRoutedEventArgs.cs