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
- SchemaEntity.cs
- ScrollProperties.cs
- LostFocusEventManager.cs
- StringCollection.cs
- SoapMessage.cs
- TimerExtension.cs
- DefaultTextStore.cs
- CurrentChangingEventManager.cs
- GridSplitterAutomationPeer.cs
- AmbientProperties.cs
- SimpleNameService.cs
- WeakReferenceKey.cs
- DocumentPage.cs
- HMACSHA1.cs
- UIElementHelper.cs
- FixedPageProcessor.cs
- SchemaImporterExtensionsSection.cs
- PreloadHost.cs
- XamlWriter.cs
- CoTaskMemUnicodeSafeHandle.cs
- BinaryReader.cs
- ToolStripScrollButton.cs
- Content.cs
- InvalidAsynchronousStateException.cs
- XmlSchemaInfo.cs
- ChildChangedEventArgs.cs
- FreezableCollection.cs
- ObjectComplexPropertyMapping.cs
- XmlSchemaAppInfo.cs
- BitmapEffectDrawing.cs
- Int32AnimationBase.cs
- WebPartConnectionsCancelVerb.cs
- StatusBar.cs
- SelectorAutomationPeer.cs
- SqlWorkflowInstanceStore.cs
- XmlBindingWorker.cs
- GenericEnumerator.cs
- TitleStyle.cs
- FontDifferentiator.cs
- DashStyles.cs
- CompressEmulationStream.cs
- HttpWebRequestElement.cs
- Odbc32.cs
- DataTableTypeConverter.cs
- DataConnectionHelper.cs
- RoutedCommand.cs
- PrinterUnitConvert.cs
- Substitution.cs
- ValueHandle.cs
- EntityObject.cs
- RecognitionResult.cs
- InputLangChangeRequestEvent.cs
- ISFTagAndGuidCache.cs
- FunctionDescription.cs
- TextRangeSerialization.cs
- AspNetHostingPermission.cs
- SafeHandles.cs
- AlphaSortedEnumConverter.cs
- Application.cs
- SQLDecimalStorage.cs
- TemplateControlCodeDomTreeGenerator.cs
- DispatcherOperation.cs
- ProxyRpc.cs
- CallInfo.cs
- RuntimeWrappedException.cs
- NumberFunctions.cs
- SaveFileDialog.cs
- ResXResourceWriter.cs
- FrameworkContentElement.cs
- HitTestWithGeometryDrawingContextWalker.cs
- Script.cs
- StorageEntitySetMapping.cs
- XamlDesignerSerializationManager.cs
- MemoryMappedView.cs
- ListBoxAutomationPeer.cs
- QueryContinueDragEvent.cs
- XsltOutput.cs
- WindowsRegion.cs
- OdbcFactory.cs
- PropertyEmitter.cs
- BitStack.cs
- TemplateControl.cs
- KeyBinding.cs
- XmlSignatureProperties.cs
- TimeEnumHelper.cs
- WindowsTitleBar.cs
- VirtualPathProvider.cs
- DataServiceQueryProvider.cs
- PixelFormatConverter.cs
- XsdCachingReader.cs
- XmlQueryContext.cs
- CallSiteOps.cs
- RemoteWebConfigurationHostServer.cs
- HttpRequestWrapper.cs
- WebControlsSection.cs
- RSACryptoServiceProvider.cs
- DbConnectionPoolCounters.cs
- HttpCookieCollection.cs
- LocalClientSecuritySettingsElement.cs
- HeaderedContentControl.cs