Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1305376 / 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
- NativeMethods.cs
- Module.cs
- NumberAction.cs
- KnownTypesProvider.cs
- DynamicObjectAccessor.cs
- Line.cs
- MaskDescriptor.cs
- RecordBuilder.cs
- DataSourceDescriptorCollection.cs
- XmlSchemaRedefine.cs
- DelegateHelpers.cs
- DuplicateWaitObjectException.cs
- Mutex.cs
- RtType.cs
- ServerProtocol.cs
- LineSegment.cs
- PanelDesigner.cs
- LineInfo.cs
- TextServicesHost.cs
- LineBreak.cs
- ButtonColumn.cs
- LocationEnvironment.cs
- InvalidProgramException.cs
- XmlTextReaderImplHelpers.cs
- TokenizerHelper.cs
- Socket.cs
- XmlSchemaGroupRef.cs
- ipaddressinformationcollection.cs
- ModelItemImpl.cs
- XmlDataLoader.cs
- RtfToken.cs
- HuffmanTree.cs
- DLinqDataModelProvider.cs
- CharUnicodeInfo.cs
- XmlName.cs
- WindowsAuthenticationEventArgs.cs
- PartialTrustVisibleAssembly.cs
- Operand.cs
- PropertyDescriptorGridEntry.cs
- PageThemeBuildProvider.cs
- FilterQuery.cs
- RectangleF.cs
- WhitespaceRuleReader.cs
- RuntimeConfigLKG.cs
- SiteMapPath.cs
- ContentControl.cs
- Section.cs
- NamespaceInfo.cs
- dsa.cs
- PropertyNames.cs
- ObjectViewFactory.cs
- ContractInferenceHelper.cs
- PolyLineSegment.cs
- ElasticEase.cs
- SecurityTokenAttachmentMode.cs
- Int32CollectionConverter.cs
- RegistryKey.cs
- TimeoutException.cs
- BookmarkScopeInfo.cs
- GenerateTemporaryAssemblyTask.cs
- DefaultPrintController.cs
- Speller.cs
- LinqDataSourceInsertEventArgs.cs
- RelatedEnd.cs
- AppDomainAttributes.cs
- FormsAuthenticationModule.cs
- WindowsSolidBrush.cs
- SqlDeflator.cs
- OwnerDrawPropertyBag.cs
- CheckBoxPopupAdapter.cs
- ReceiveMessageRecord.cs
- ToolStripScrollButton.cs
- FilteredAttributeCollection.cs
- WebPartHeaderCloseVerb.cs
- MissingMethodException.cs
- IDReferencePropertyAttribute.cs
- CodeTypeOfExpression.cs
- CryptographicAttribute.cs
- EdmSchemaError.cs
- XmlBinaryReader.cs
- MimeMultiPart.cs
- dsa.cs
- DataGridViewCellStyleBuilderDialog.cs
- TextSyndicationContentKindHelper.cs
- HtmlContainerControl.cs
- SqlXml.cs
- UpdatePanelTriggerCollection.cs
- ColumnHeader.cs
- SecurityListenerSettingsLifetimeManager.cs
- QueryOpeningEnumerator.cs
- ExtensionSurface.cs
- SslStream.cs
- StrongTypingException.cs
- SemanticValue.cs
- LiteralControl.cs
- LongPath.cs
- XmlSchemaObjectCollection.cs
- SemanticResultValue.cs
- StoreItemCollection.cs
- IriParsingElement.cs