Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 5 / 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
- XmlBinaryReader.cs
- StyleCollection.cs
- SchemaObjectWriter.cs
- SystemResourceHost.cs
- FacetDescription.cs
- HtmlPhoneCallAdapter.cs
- UnionCqlBlock.cs
- TemplateControlParser.cs
- ActivityExecutionWorkItem.cs
- XslException.cs
- ConstraintCollection.cs
- Missing.cs
- WindowsProgressbar.cs
- TypeForwardedToAttribute.cs
- NativeMethods.cs
- ToolStripCollectionEditor.cs
- UserUseLicenseDictionaryLoader.cs
- TextCompositionEventArgs.cs
- XmlExpressionDumper.cs
- MasterPageParser.cs
- Schema.cs
- Int16KeyFrameCollection.cs
- EllipseGeometry.cs
- ConcurrentBag.cs
- Stream.cs
- SmiEventSink_Default.cs
- Style.cs
- MethodCallConverter.cs
- HtmlHead.cs
- StateItem.cs
- RequestSecurityTokenResponse.cs
- ContextBase.cs
- Inflater.cs
- MULTI_QI.cs
- ConstantSlot.cs
- BitmapMetadata.cs
- SystemUdpStatistics.cs
- SqlVisitor.cs
- FixedTextContainer.cs
- PocoEntityKeyStrategy.cs
- NodeLabelEditEvent.cs
- DataGridViewBindingCompleteEventArgs.cs
- OLEDB_Util.cs
- TTSVoice.cs
- SecurityChannel.cs
- ObjectRef.cs
- UrlMappingCollection.cs
- HtmlUtf8RawTextWriter.cs
- DynamicUpdateCommand.cs
- MaxMessageSizeStream.cs
- ZoomPercentageConverter.cs
- SafeSecurityHandles.cs
- GradientStop.cs
- SafeRightsManagementHandle.cs
- XmlSerializer.cs
- BufferedGraphicsManager.cs
- TextChange.cs
- BuildProviderCollection.cs
- ImmComposition.cs
- TypeToken.cs
- VisualBrush.cs
- DockProviderWrapper.cs
- AtomPub10ServiceDocumentFormatter.cs
- FlowDecisionDesigner.xaml.cs
- DbProviderFactory.cs
- FontFamily.cs
- OrderPreservingPipeliningMergeHelper.cs
- NoneExcludedImageIndexConverter.cs
- ContextMenuStrip.cs
- SynchronizedChannelCollection.cs
- httpstaticobjectscollection.cs
- ResourcesBuildProvider.cs
- PagedDataSource.cs
- SimplePropertyEntry.cs
- WindowsAltTab.cs
- XmlAttribute.cs
- EdmMember.cs
- PropertyRef.cs
- Property.cs
- KnowledgeBase.cs
- HttpVersion.cs
- HtmlTernaryTree.cs
- TextEditorLists.cs
- XmlSchemaFacet.cs
- SoapIncludeAttribute.cs
- TakeOrSkipQueryOperator.cs
- StaticTextPointer.cs
- EventLogTraceListener.cs
- InitializerFacet.cs
- Buffer.cs
- ContainerUIElement3D.cs
- Parser.cs
- CounterSampleCalculator.cs
- TransformPatternIdentifiers.cs
- ProtocolsSection.cs
- SqlConnection.cs
- CheckBoxStandardAdapter.cs
- DateTimeFormatInfo.cs
- SafeRegistryKey.cs
- StrongNameSignatureInformation.cs