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
- Accessible.cs
- NonSerializedAttribute.cs
- DeflateStream.cs
- X509Chain.cs
- WorkflowApplicationException.cs
- Typography.cs
- Material.cs
- assemblycache.cs
- UserInitiatedNavigationPermission.cs
- HtmlSelect.cs
- FreezableDefaultValueFactory.cs
- SecurityTokenException.cs
- BaseHashHelper.cs
- ByteStream.cs
- AuthorizationContext.cs
- AnnotationResource.cs
- EndEvent.cs
- ItemsPresenter.cs
- DataMemberConverter.cs
- DataGridViewCellFormattingEventArgs.cs
- SqlFunctions.cs
- DatatypeImplementation.cs
- _NestedSingleAsyncResult.cs
- CornerRadiusConverter.cs
- CheckBox.cs
- CodeConditionStatement.cs
- KeyboardEventArgs.cs
- DrawingImage.cs
- BlockExpression.cs
- HtmlTitle.cs
- OdbcDataAdapter.cs
- SoapFault.cs
- mediaeventargs.cs
- ReadWriteControlDesigner.cs
- CodeDelegateCreateExpression.cs
- FamilyTypefaceCollection.cs
- SystemWebExtensionsSectionGroup.cs
- HttpClientCertificate.cs
- DataServiceQueryException.cs
- PictureBox.cs
- RenderCapability.cs
- ProtocolsConfigurationHandler.cs
- DrawingAttributesDefaultValueFactory.cs
- EnumMember.cs
- ConfigurationManagerInternalFactory.cs
- BinaryQueryOperator.cs
- CounterSampleCalculator.cs
- ControlPaint.cs
- OleTxTransactionInfo.cs
- ClientSettingsSection.cs
- AppSecurityManager.cs
- ClassHandlersStore.cs
- TriState.cs
- XPathNodeList.cs
- HandlerMappingMemo.cs
- Container.cs
- _LazyAsyncResult.cs
- MsdtcClusterUtils.cs
- BindingMemberInfo.cs
- EFAssociationProvider.cs
- ArgumentOutOfRangeException.cs
- Encoder.cs
- DefaultObjectMappingItemCollection.cs
- MsmqAppDomainProtocolHandler.cs
- ProxyWebPartManager.cs
- ButtonFlatAdapter.cs
- Vertex.cs
- ConditionalBranch.cs
- _AutoWebProxyScriptWrapper.cs
- CustomErrorsSection.cs
- EffectiveValueEntry.cs
- GridViewSelectEventArgs.cs
- CategoryState.cs
- EmptyTextWriter.cs
- ArrangedElementCollection.cs
- SqlDataSourceQueryEditor.cs
- LabelAutomationPeer.cs
- LoginView.cs
- EnlistmentTraceIdentifier.cs
- DataIdProcessor.cs
- TextServicesCompartmentEventSink.cs
- DataBindingCollection.cs
- NamespaceInfo.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DbConnectionPoolCounters.cs
- InkCanvasInnerCanvas.cs
- AuthenticateEventArgs.cs
- BitConverter.cs
- Deflater.cs
- List.cs
- ListBoxChrome.cs
- EdmItemError.cs
- Ref.cs
- PriorityQueue.cs
- Slider.cs
- ListBindingConverter.cs
- RepeatBehaviorConverter.cs
- MetadataProperty.cs
- HwndSourceParameters.cs
- EventEntry.cs