Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- AssemblyCollection.cs
- GenerateTemporaryAssemblyTask.cs
- BoolExpression.cs
- ArgumentValidation.cs
- WindowsTokenRoleProvider.cs
- ResourcesGenerator.cs
- DoubleAnimation.cs
- SchemaImporter.cs
- StylusButtonCollection.cs
- APCustomTypeDescriptor.cs
- SQLString.cs
- ObservableDictionary.cs
- MiniModule.cs
- WebServiceHandler.cs
- XmlCodeExporter.cs
- StringReader.cs
- WebPartConnectionsConnectVerb.cs
- SystemGatewayIPAddressInformation.cs
- HtmlInputSubmit.cs
- ProfileSettings.cs
- ClickablePoint.cs
- MultipartContentParser.cs
- SimpleWorkerRequest.cs
- Style.cs
- StateRuntime.cs
- AmbientLight.cs
- ClientRoleProvider.cs
- QueryExecutionOption.cs
- ObjectDataSourceView.cs
- DetailsViewPageEventArgs.cs
- HandleExceptionArgs.cs
- IsolationInterop.cs
- ItemCollection.cs
- RelatedEnd.cs
- DataKeyCollection.cs
- CodeMethodInvokeExpression.cs
- GACIdentityPermission.cs
- DbDataSourceEnumerator.cs
- LookupNode.cs
- TrustLevelCollection.cs
- PeerName.cs
- IntegerValidatorAttribute.cs
- CommandLibraryHelper.cs
- ContextQuery.cs
- DetailsViewRowCollection.cs
- RemotingService.cs
- Margins.cs
- KnownIds.cs
- WebPartCancelEventArgs.cs
- AuthenticationConfig.cs
- GlyphsSerializer.cs
- ImageListStreamer.cs
- WebPermission.cs
- PerformanceCounterManager.cs
- FontCollection.cs
- CodeTypeReferenceCollection.cs
- ClientRoleProvider.cs
- RTLAwareMessageBox.cs
- SortableBindingList.cs
- HierarchicalDataSourceIDConverter.cs
- XPathNavigatorException.cs
- QueryCacheKey.cs
- MemoryMappedView.cs
- TraceContextEventArgs.cs
- ProtocolProfile.cs
- ExeConfigurationFileMap.cs
- PersianCalendar.cs
- ImageKeyConverter.cs
- ServiceDescriptionSerializer.cs
- PlanCompilerUtil.cs
- Popup.cs
- SearchForVirtualItemEventArgs.cs
- VisualTreeUtils.cs
- MimeParameters.cs
- OSFeature.cs
- XmlImplementation.cs
- DtrList.cs
- NativeCompoundFileAPIs.cs
- ParserStack.cs
- QueueProcessor.cs
- RegexCaptureCollection.cs
- RijndaelManagedTransform.cs
- altserialization.cs
- DataGridViewCheckBoxCell.cs
- DoubleLinkListEnumerator.cs
- TrackingMemoryStreamFactory.cs
- CodeVariableReferenceExpression.cs
- UserControl.cs
- SizeFConverter.cs
- RowToParametersTransformer.cs
- ExpressionBuilderContext.cs
- GotoExpression.cs
- DecoderNLS.cs
- DifferencingCollection.cs
- ToolStripMenuItemDesigner.cs
- ErrorFormatterPage.cs
- HealthMonitoringSection.cs
- GridViewItemAutomationPeer.cs
- ScrollBar.cs
- CompleteWizardStep.cs