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
- DataRow.cs
- UrlPath.cs
- DependencyPropertyValueSerializer.cs
- LocatorManager.cs
- Substitution.cs
- TrustManagerPromptUI.cs
- GeometryModel3D.cs
- AsymmetricKeyExchangeDeformatter.cs
- XmlEncodedRawTextWriter.cs
- XhtmlBasicLiteralTextAdapter.cs
- DataGrid.cs
- XmlSchemaValidator.cs
- TextReader.cs
- Mapping.cs
- EncoderReplacementFallback.cs
- Configuration.cs
- IMembershipProvider.cs
- DataGridCellsPanel.cs
- _SslStream.cs
- RenderingEventArgs.cs
- Soap.cs
- BookmarkList.cs
- TypeSystem.cs
- TextViewSelectionProcessor.cs
- TypeDelegator.cs
- SqlDependency.cs
- KeyBinding.cs
- ProcessingInstructionAction.cs
- RectangleConverter.cs
- UpdateManifestForBrowserApplication.cs
- SerialPinChanges.cs
- Stack.cs
- HwndSourceParameters.cs
- ValueType.cs
- ISCIIEncoding.cs
- BitmapFrameDecode.cs
- ListViewPagedDataSource.cs
- ClickablePoint.cs
- KeyEvent.cs
- SmtpReplyReaderFactory.cs
- DbDataSourceEnumerator.cs
- BinaryConverter.cs
- XamlReader.cs
- WeakReferenceList.cs
- ImmutableCollection.cs
- ObjectListField.cs
- DefaultTraceListener.cs
- PtsHelper.cs
- SafeHandles.cs
- LineMetrics.cs
- EntityRecordInfo.cs
- safex509handles.cs
- PlanCompilerUtil.cs
- SettingsPropertyWrongTypeException.cs
- BrowserTree.cs
- TextEditor.cs
- WorkflowRuntimeElement.cs
- RtfFormatStack.cs
- _NetRes.cs
- Stack.cs
- NestedContainer.cs
- FileLogRecord.cs
- XPathAxisIterator.cs
- HttpAsyncResult.cs
- ToolStripScrollButton.cs
- HwndHostAutomationPeer.cs
- BooleanSwitch.cs
- DataBinder.cs
- EvidenceTypeDescriptor.cs
- SelectedDatesCollection.cs
- BamlTreeUpdater.cs
- AuthenticationServiceManager.cs
- ServiceManager.cs
- MarkupExtensionReturnTypeAttribute.cs
- LogLogRecordEnumerator.cs
- DodSequenceMerge.cs
- WindowsGraphics2.cs
- validationstate.cs
- UrlMappingsModule.cs
- CompilerCollection.cs
- ProjectionPruner.cs
- HttpCachePolicyElement.cs
- Point3DCollectionConverter.cs
- ColumnTypeConverter.cs
- FixedStringLookup.cs
- XmlSchemaInfo.cs
- Menu.cs
- GenerateHelper.cs
- DelegatingTypeDescriptionProvider.cs
- Baml2006KeyRecord.cs
- DataControlImageButton.cs
- Transactions.cs
- QueryCacheKey.cs
- CounterCreationData.cs
- SqlFormatter.cs
- AnnotationMap.cs
- BufferedGraphicsContext.cs
- MarkupCompilePass1.cs
- ValidatingPropertiesEventArgs.cs
- XamlTreeBuilderBamlRecordWriter.cs