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
- DbConnectionOptions.cs
- DrawingGroup.cs
- GridViewAutoFormat.cs
- ValueType.cs
- DeviceContexts.cs
- DeferredRunTextReference.cs
- QuaternionIndependentAnimationStorage.cs
- FixedHyperLink.cs
- WindowsListViewGroupHelper.cs
- ProfileServiceManager.cs
- DataServiceBehavior.cs
- HtmlEncodedRawTextWriter.cs
- PersonalizationState.cs
- TextEditorTables.cs
- DataSysAttribute.cs
- ByteAnimation.cs
- DataServiceException.cs
- TemplateManager.cs
- BinHexDecoder.cs
- RootNamespaceAttribute.cs
- Timer.cs
- SEHException.cs
- SqlDataSourceQuery.cs
- DelegateHelpers.Generated.cs
- DataServiceRequestException.cs
- compensatingcollection.cs
- IDispatchConstantAttribute.cs
- DecimalAnimationBase.cs
- ListDictionary.cs
- DataSvcMapFileSerializer.cs
- ObjectSecurityT.cs
- XmlSchemaGroup.cs
- XhtmlConformanceSection.cs
- ReadOnlyCollectionBuilder.cs
- BufferedGraphicsContext.cs
- Geometry3D.cs
- InstanceNotFoundException.cs
- RangeEnumerable.cs
- ImageBrush.cs
- MaterialGroup.cs
- ProjectionCamera.cs
- BinaryFormatterSinks.cs
- ProcessHostServerConfig.cs
- DocumentGridPage.cs
- HijriCalendar.cs
- XmlElementCollection.cs
- GridViewEditEventArgs.cs
- DataReaderContainer.cs
- ErrorHandler.cs
- TableAdapterManagerHelper.cs
- SqlBuilder.cs
- NameObjectCollectionBase.cs
- DiagnosticTrace.cs
- EngineSite.cs
- MbpInfo.cs
- UseManagedPresentationBindingElementImporter.cs
- TickBar.cs
- InternalConfigHost.cs
- DiagnosticsConfigurationHandler.cs
- RepeaterCommandEventArgs.cs
- XmlSchemaExternal.cs
- SafeSecurityHandles.cs
- ControlIdConverter.cs
- WindowsIPAddress.cs
- LinqDataSourceDisposeEventArgs.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- AttachmentService.cs
- WebResponse.cs
- ChameleonKey.cs
- DesignerVerb.cs
- VirtualPathProvider.cs
- WebHttpBindingElement.cs
- LongValidatorAttribute.cs
- PrintDialog.cs
- DataGridViewTextBoxCell.cs
- GeometryDrawing.cs
- UInt32Converter.cs
- DocumentStatusResources.cs
- AccessViolationException.cs
- HttpPostedFile.cs
- Matrix3DStack.cs
- OutputScopeManager.cs
- SHA256CryptoServiceProvider.cs
- ClientSession.cs
- InkCanvasFeedbackAdorner.cs
- SocketException.cs
- XmlComplianceUtil.cs
- TabItemWrapperAutomationPeer.cs
- SqlDelegatedTransaction.cs
- TrackPoint.cs
- RedirectionProxy.cs
- TextDecorationUnitValidation.cs
- _ConnectionGroup.cs
- ObjectDataSourceMethodEventArgs.cs
- BCLDebug.cs
- EdmItemError.cs
- HtmlForm.cs
- BindingManagerDataErrorEventArgs.cs
- _AcceptOverlappedAsyncResult.cs
- CacheVirtualItemsEvent.cs