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
- QueryMath.cs
- SkinBuilder.cs
- DateTimeConverter.cs
- ElementHostAutomationPeer.cs
- XmlSchemaExternal.cs
- HostedHttpTransportManager.cs
- SQLMembershipProvider.cs
- FocusWithinProperty.cs
- NaturalLanguageHyphenator.cs
- StructuredTypeInfo.cs
- TextBox.cs
- ConnectionInterfaceCollection.cs
- TreeIterators.cs
- SimpleHandlerBuildProvider.cs
- JoinTreeNode.cs
- DataControlPagerLinkButton.cs
- SiteMembershipCondition.cs
- DockPatternIdentifiers.cs
- ProfileManager.cs
- PostBackOptions.cs
- WindowsListViewSubItem.cs
- AxisAngleRotation3D.cs
- BrowserTree.cs
- EntitySqlQueryState.cs
- OleDbStruct.cs
- SmtpCommands.cs
- SamlSubjectStatement.cs
- PeerHopCountAttribute.cs
- ResourcePool.cs
- XmlValidatingReader.cs
- FilterEventArgs.cs
- ContainerFilterService.cs
- Stylesheet.cs
- ProxyWebPartManagerDesigner.cs
- ApplicationException.cs
- ThreadTrace.cs
- sqlstateclientmanager.cs
- TripleDES.cs
- InstancePersistence.cs
- PropertyReferenceSerializer.cs
- SQLDateTimeStorage.cs
- AssertHelper.cs
- Size3D.cs
- EditorOptionAttribute.cs
- ContravarianceAdapter.cs
- ListDictionaryInternal.cs
- StorageMappingFragment.cs
- SortedDictionary.cs
- Color.cs
- ToolStripPanelRow.cs
- PageCatalogPartDesigner.cs
- AttachedAnnotation.cs
- ConfigXmlComment.cs
- MetadataUtilsSmi.cs
- OdbcParameter.cs
- TextRunProperties.cs
- TextSelectionHighlightLayer.cs
- DataStreamFromComStream.cs
- ModuleBuilder.cs
- TranslateTransform3D.cs
- RemoteTokenFactory.cs
- _NegoState.cs
- Collection.cs
- GridViewUpdatedEventArgs.cs
- BufferedReadStream.cs
- LinearKeyFrames.cs
- ExceptQueryOperator.cs
- BooleanConverter.cs
- FileNotFoundException.cs
- BinaryUtilClasses.cs
- ItemChangedEventArgs.cs
- MemberJoinTreeNode.cs
- LoaderAllocator.cs
- FixedSchema.cs
- TemplateKey.cs
- CallbackHandler.cs
- GroupBox.cs
- RequestCacheManager.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- M3DUtil.cs
- ErrorHandler.cs
- TrackingLocationCollection.cs
- OletxResourceManager.cs
- JobDuplex.cs
- UTF7Encoding.cs
- ContractComponent.cs
- MediaTimeline.cs
- WSUtilitySpecificationVersion.cs
- DataPager.cs
- SiteIdentityPermission.cs
- ContainerUIElement3D.cs
- SecureStringHasher.cs
- PropertyIdentifier.cs
- CanonicalizationDriver.cs
- SQLDecimalStorage.cs
- FormsAuthenticationTicket.cs
- ActiveXHost.cs
- _ShellExpression.cs
- DesignerLoader.cs
- Matrix.cs