Server IP : 103.118.17.23 / Your IP : 216.73.216.188 Web Server : Microsoft-IIS/10.0 System : Windows NT RESELLERPLESK22 10.0 build 20348 (Windows Server 2016) AMD64 User : IWAM_plesk(default) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/vhosts/mesa.org.in/httpdocs/assets/_core/php/examples/other_controls/ |
Upload File : |
<?php require('../includes/header.inc.php'); ?> <div id="instructions"> <h1>Persistent Controls: Performance for Reusable Components</h1> <p>What do you do if you have an element that's shared between multiple pages that's computationally intensive to produce? For example, what would you do in a situation where you have a dropdown control in the navigation, and that dropdown is populated with a list of projects from a database? Or worse, with a result of some heavy query?</p> <p>An obvious answer is to try to cache the results of the query so that you don't have to run it every time a page is loaded. QCubed comes with a feature called Persistent Controls that might save you time in certain situations. It works exactly as it sounds: all control metadata is cached by QCubed in the session state ($_SESSION). The next time a page is loaded, control state for persistent controls will be loaded from the session (which is much faster than trying to execute the query again).</p> <p>Try <a href="persist.php">reloading this page</a> and observe the status label underneath the dropdown. Note that if you run this example again, as long as your session state is not wiped, you'll never see the query executed - control storage is, well, persistent. </p> <p>Several notes:</p> <ol> <li>If you want to create a reusable component that will work across user sessions (and will reuse the data from the session of one user to the session of another), Persistent Controls won't help. Use the <b>QCache</b> instead - take a look at QueryArrayCached (<a href="../qcubed_query/qcache.php">example</a>).</li> <li>Be mindful of the memory footprint of storing the <i>entire control</i> in the $_SESSION. In the example below, the footprint of the tiny dropdown with four values is 4KBytes. Persistent Controls can easily turn into a memory hog if you don't watch for it.</li> </ol> </div> <div id="demoZone"> <?php $this->RenderBegin(); ?> <?php $this->ddnProjectPicker->Render(); ?></p> <?php $this->lblStatus->Render(); ?></p> <a href="persist.php">Reload the page</a> <?php $this->RenderEnd(); ?> </div> <?php require('../includes/footer.inc.php'); ?>