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
- OdbcTransaction.cs
- ToolStripDropDown.cs
- PolicyValidationException.cs
- DetailsViewRow.cs
- JapaneseCalendar.cs
- HuffmanTree.cs
- SpeechAudioFormatInfo.cs
- FilterElement.cs
- TextMetrics.cs
- XamlFigureLengthSerializer.cs
- smtppermission.cs
- HandlerBase.cs
- SHA384.cs
- EventLogger.cs
- PhysicalFontFamily.cs
- SqlDataSourceCommandEventArgs.cs
- ColumnMapTranslator.cs
- PreservationFileWriter.cs
- EntitySqlException.cs
- SqlParameter.cs
- GlobalizationAssembly.cs
- DiscoveryMessageProperty.cs
- HuffmanTree.cs
- versioninfo.cs
- Menu.cs
- BuildDependencySet.cs
- EventItfInfo.cs
- ProxyWebPartManager.cs
- TextEndOfSegment.cs
- LabelAutomationPeer.cs
- IntegerValidator.cs
- TableCell.cs
- Sql8ConformanceChecker.cs
- CreationContext.cs
- DataServiceHostFactory.cs
- WebPartCatalogAddVerb.cs
- HashCodeCombiner.cs
- TabPage.cs
- Buffer.cs
- CompModSwitches.cs
- ThreadPool.cs
- CreateSequenceResponse.cs
- DataTableReaderListener.cs
- X509ThumbprintKeyIdentifierClause.cs
- NameTable.cs
- ImportContext.cs
- TcpSocketManager.cs
- RenderCapability.cs
- AssociationType.cs
- CryptoApi.cs
- DefaultAuthorizationContext.cs
- PageVisual.cs
- Brush.cs
- ProxyWebPart.cs
- Bits.cs
- FrameworkContentElement.cs
- SingleObjectCollection.cs
- UnsafeNativeMethodsCLR.cs
- SelectionItemPattern.cs
- SchemaSetCompiler.cs
- TrustVersion.cs
- DbSourceCommand.cs
- AutoCompleteStringCollection.cs
- DataServiceExpressionVisitor.cs
- FlowDocument.cs
- IdnElement.cs
- SelectionEditingBehavior.cs
- ZipIOLocalFileHeader.cs
- XmlDataSourceView.cs
- PartialTrustVisibleAssembly.cs
- GeometryGroup.cs
- GregorianCalendar.cs
- BuildManager.cs
- Constraint.cs
- SQLMoney.cs
- JsonXmlDataContract.cs
- Solver.cs
- TemplateKeyConverter.cs
- Dispatcher.cs
- ButtonChrome.cs
- GetIndexBinder.cs
- SecurityContextSecurityTokenParameters.cs
- GenericAuthenticationEventArgs.cs
- TextPattern.cs
- ManagedIStream.cs
- KerberosSecurityTokenAuthenticator.cs
- GridEntry.cs
- AsymmetricSignatureFormatter.cs
- HttpWriter.cs
- TdsParserSafeHandles.cs
- PathSegment.cs
- WinEventTracker.cs
- RelationshipConstraintValidator.cs
- NetworkInformationPermission.cs
- ContextProperty.cs
- ObjectStateFormatter.cs
- AdvancedBindingPropertyDescriptor.cs
- SettingsProperty.cs
- PageContent.cs
- CustomErrorsSectionWrapper.cs