logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

SF.net SVN: mantisbt: [4740] trunk/mantisbt/core/user_api.php: msg#00045

Subject: SF.net SVN: mantisbt: [4740] trunk/mantisbt/core/user_api.php
Revision: 4740
          http://mantisbt.svn.sourceforge.net/mantisbt/?rev=4740&view=rev
Author:   prichards
Date:     2007-11-10 16:33:28 -0800 (Sat, 10 Nov 2007)

Log Message:
-----------
Add user_update_cache function that provides a quick way to update a cached 
field without reloading the data from the DB. This saves a query on each page 
atm for last_visited value.

Modified Paths:
--------------
    trunk/mantisbt/core/user_api.php

Modified: trunk/mantisbt/core/user_api.php
===================================================================
--- trunk/mantisbt/core/user_api.php    2007-11-11 00:21:38 UTC (rev 4739)
+++ trunk/mantisbt/core/user_api.php    2007-11-11 00:33:28 UTC (rev 4740)
@@ -88,6 +88,16 @@
                return true;
        }
 
+       function user_update_cache( $p_user_id, $p_field, $p_value ) {
+               global $g_cache_user;
+
+               if ( isset( $g_cache_user[$p_user_id] ) && isset ( 
$g_cache_user[$p_user_id][$p_field] ) ) {
+                       $g_cache_user[$p_user_id][$p_field] = $p_value;
+               } else {
+                       user_clear_cache( $p_user_id );
+               }
+       }
+       
        #===================================
        # Boolean queries and ensures
        #===================================
@@ -962,16 +972,17 @@
        # Update the last_visited field to be now
        function user_update_last_visit( $p_user_id ) {
                $c_user_id = db_prepare_int( $p_user_id );
+               $c_value = db_now();
 
                $t_user_table = config_get_global( 'mantis_user_table' );
-
+               
                $query = "UPDATE $t_user_table
-                                 SET last_visit= " . db_now() . "
-                                 WHERE id=" . db_param(0);
+                                 SET last_visit= " . $c_value . "
+                                 WHERE id=" . db_param(1);
 
                db_query_bound( $query, Array( $c_user_id ) );
 
-               user_clear_cache( $p_user_id );
+               user_update_cache($p_user_id, 'last_visit', $c_value);
 
                #db_query errors on failure so:
                return true;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/


<Prev in Thread] Current Thread [Next in Thread>