DNN Blog

Apr 20

Posted by: Charles Nurse
4/20/2007  RssIcon

DotNetNuke 4.4 introduced a number of performance enhancements.  Many of these enhancements required the creation of new overloads of some common methods and deprecation of the existing methods.

It is important for module developers, who wish their modules to take advantage of the new performance features to update their modules for performance.

There are a couple of methods specifically that should probably be looked at.

ModuleController.GetModule(moduleID, tabID)

This method which existed prior to 4.4 was replaced by an overload that has an extra parameter (ignoreCache).  This parameter determines whether the module is fetched from the cache (ignoreCache = false) or the database (ignoreCache=true).  The old method calls the new method with the setting ignoreCache = true - which means that the call always goes to the database.

The implementation was done this way so that the expected behaviour did not change.  However, it measn that module developers who wish to use the cache should add the ignoreCache=false parameter to their calls.

ModulePermissionController.HasModulePermission(moduleID, permissionKey)

This method that existed prior to 4.4, enabled a Module Developer to determine whther a user had a specific Module Permission.  As the module permissions are now cached by the TabID - this method cannot take advantage of the module permission cache.  (Note: the ModulePermissionCache is a Dictionary - where the keys are the moduleID and the values are the permissions for the module - this dictionary is then stored in the cache using a key based on the TabID)

Thus, if your module calls this overload of HasModulePermission it will always make a call to the stored procedure GetModulePermissionsByModuleID, bypassing the cache, and any performance improvements  You can fix this by using one of two overloads:

  • HasModulePermission(moduleID, tabID, permissionKey) - this new overload adds the tabId to the parameter list so the module permissions collection can be looked up in the appropriate Dictionary in the cache
  • HasModulePermission(modulepermissions, permissionKey) - this overload that existed prior to 4.4 passes the modulepermissions as a parameter.  In PortalModuleBase, the ModuleConfiguration property has a reference to the ModulePermissions - as does any instance of the ModuleInfo object.

There are other methods, of course, that should be checked.  4.5 added Folder and FolderPermission caching.  The simplest way to determine whether you need to upgrade your module is to open it in Visual Studio and look for "This method is Obsolete" syntax warnings.

Tags:
Categories:
Location: Blogs Parent Separator Charles Nurse

2 comment(s) so far...


Re: Performance, Performance, Performance - Using the correct methods

thanks, i have this article translate into chinese

By xujun on   4/21/2007

Re: Performance, Performance, Performance - Using the correct methods

Good article, i published a Turkish summary at my blog page.

By greenflash on   4/21/2007
Attend A Webinar
Try An Online Demo
Download DotNetNuke Professional Edition Trial
Have Someone Contact Me

Like Us on Facebook Join our Network on LinkedIn Follow DNN Corporate on Twitter Follow DNN on Twitter

Advertisers

Sponsors

DotNetNuke Corporation

DotNetNuke Corp. is the steward of the DotNetNuke open source project, the most widely adopted Web Content Management Platform for building web sites and web applications on Microsoft .NET. Organizations use DotNetNuke to quickly develop and deploy interactive and dynamic web sites, intranets, extranets and web applications. The DotNetNuke platform is available in a free Community and subscription-based Professional and Enterprise Editions with an Elite Support option. DotNetNuke Corp. also operates Snowcovered.com where users purchase third party apps for the platform.