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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GridToolTip.cs
- Trace.cs
- SoapAttributes.cs
- CmsInterop.cs
- SystemPens.cs
- TypeHelper.cs
- XslCompiledTransform.cs
- PageOutputColor.cs
- DataGridViewComponentPropertyGridSite.cs
- LowerCaseStringConverter.cs
- CssTextWriter.cs
- DataServiceEntityAttribute.cs
- ArrayTypeMismatchException.cs
- DeflateEmulationStream.cs
- Calendar.cs
- Stopwatch.cs
- SqlErrorCollection.cs
- ConnectionOrientedTransportBindingElement.cs
- ElementAction.cs
- DBPropSet.cs
- ImageMetadata.cs
- WebPartMovingEventArgs.cs
- IsolatedStorageException.cs
- MenuEventArgs.cs
- ExtensionWindowHeader.cs
- MimeFormatter.cs
- SafeRegistryKey.cs
- DataFormats.cs
- TemplatePartAttribute.cs
- ReflectionTypeLoadException.cs
- StateWorkerRequest.cs
- DirtyTextRange.cs
- BuiltInPermissionSets.cs
- Odbc32.cs
- ImageAttributes.cs
- StringHandle.cs
- SQLInt32.cs
- CodeAttributeArgument.cs
- UrlAuthorizationModule.cs
- TreeNodeEventArgs.cs
- CaretElement.cs
- ClientApiGenerator.cs
- BehaviorEditorPart.cs
- SecurityTokenProvider.cs
- RegexCompiler.cs
- FigureParaClient.cs
- ReadWriteObjectLock.cs
- ResourcePermissionBase.cs
- XmlNodeList.cs
- sitestring.cs
- FileIOPermission.cs
- TreePrinter.cs
- SecurityTokenResolver.cs
- Binding.cs
- DynamicUpdateCommand.cs
- ToolStripArrowRenderEventArgs.cs
- CompilerTypeWithParams.cs
- MSHTMLHost.cs
- CompositeFontInfo.cs
- FileDetails.cs
- RpcCryptoContext.cs
- AnnotationComponentManager.cs
- sitestring.cs
- HostProtectionPermission.cs
- ServerType.cs
- Int32Rect.cs
- ClonableStack.cs
- XmlLinkedNode.cs
- CodeGroup.cs
- BaseWebProxyFinder.cs
- TrimSurroundingWhitespaceAttribute.cs
- EmbeddedMailObjectsCollection.cs
- MatrixCamera.cs
- COAUTHIDENTITY.cs
- DBBindings.cs
- PerfCounters.cs
- SyndicationItemFormatter.cs
- MexServiceChannelBuilder.cs
- StringValidator.cs
- BamlMapTable.cs
- SqlBulkCopyColumnMapping.cs
- FilterException.cs
- HttpAsyncResult.cs
- WsdlBuildProvider.cs
- DbInsertCommandTree.cs
- TextServicesCompartmentContext.cs
- RolePrincipal.cs
- ContextActivityUtils.cs
- ViewStateModeByIdAttribute.cs
- RadioButtonStandardAdapter.cs
- ToolTip.cs
- TextLineResult.cs
- DbDeleteCommandTree.cs
- X509RawDataKeyIdentifierClause.cs
- GenericAuthenticationEventArgs.cs
- SimpleFileLog.cs
- URLString.cs
- ProcessHostMapPath.cs
- ObjectDataProvider.cs
- PrimitiveSchema.cs