Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 5 / 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
- SemanticValue.cs
- CheckBoxRenderer.cs
- DataGridViewCell.cs
- CngAlgorithmGroup.cs
- AccessControlList.cs
- ListViewGroupCollectionEditor.cs
- ReadOnlyCollection.cs
- IntSecurity.cs
- BaseValidator.cs
- ActivationServices.cs
- EntityModelSchemaGenerator.cs
- ConfigXmlCDataSection.cs
- GatewayDefinition.cs
- DbDataAdapter.cs
- SessionStateSection.cs
- TemplateContent.cs
- ServiceSettingsResponseInfo.cs
- Message.cs
- ApplicationHost.cs
- WindowsRichEdit.cs
- CodeMemberProperty.cs
- FormViewDeletedEventArgs.cs
- _FixedSizeReader.cs
- SoapSchemaExporter.cs
- EdmFunctions.cs
- ExternalException.cs
- ParsedAttributeCollection.cs
- FactoryRecord.cs
- Calendar.cs
- _IPv4Address.cs
- TextServicesCompartment.cs
- RectangleGeometry.cs
- Roles.cs
- XmlDataCollection.cs
- ServiceOperationWrapper.cs
- ObjectStateFormatter.cs
- GridItemCollection.cs
- GridViewColumnHeader.cs
- FileDialogCustomPlace.cs
- MultiByteCodec.cs
- VisualStyleTypesAndProperties.cs
- COAUTHIDENTITY.cs
- StylusTouchDevice.cs
- Queue.cs
- ItemType.cs
- LinkLabel.cs
- RSAOAEPKeyExchangeDeformatter.cs
- XmlMapping.cs
- VisualProxy.cs
- COM2FontConverter.cs
- LinkAreaEditor.cs
- BufferBuilder.cs
- EndpointNameMessageFilter.cs
- OneWayBindingElement.cs
- ResourceDescriptionAttribute.cs
- DependentTransaction.cs
- IgnoreDataMemberAttribute.cs
- RoleManagerEventArgs.cs
- BoundField.cs
- DrawListViewSubItemEventArgs.cs
- NameValueSectionHandler.cs
- EventHandlers.cs
- ListViewItemSelectionChangedEvent.cs
- Processor.cs
- CodeExpressionCollection.cs
- ViewBase.cs
- CookielessHelper.cs
- XPathPatternParser.cs
- RadioButtonPopupAdapter.cs
- DataGridComboBoxColumn.cs
- CodeDelegateCreateExpression.cs
- MeasureData.cs
- CharUnicodeInfo.cs
- XmlComplianceUtil.cs
- SizeChangedEventArgs.cs
- ObjectSerializerFactory.cs
- DataServiceBuildProvider.cs
- CounterSampleCalculator.cs
- oledbconnectionstring.cs
- SystemIcmpV6Statistics.cs
- HttpClientCertificate.cs
- HttpResponseMessageProperty.cs
- DragEventArgs.cs
- ExpressionNormalizer.cs
- ImportStoreException.cs
- ValidationHelper.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- QilReplaceVisitor.cs
- SelectionProviderWrapper.cs
- HtmlShim.cs
- XmlQueryType.cs
- TextOnlyOutput.cs
- BamlRecords.cs
- HandleExceptionArgs.cs
- TextDpi.cs
- CompensationExtension.cs
- ReferenceAssemblyAttribute.cs
- StrongNameIdentityPermission.cs
- Pair.cs
- TouchEventArgs.cs