Changeset 1010 for trunk/common


Ignore:
Timestamp:
03/01/09 12:43:38 (3 years ago)
Author:
bogdan2412
Message:

Cache task parent rounds

http://reviewboard.infoarena.ro/r/69/

Location:
trunk/common/db
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/round.php

    r1007 r1010  
    161161// 
    162162// $tasks is array of task id's 
    163 function round_update_task_list($round_id, $tasks) { 
     163function round_update_task_list($round_id, $old_tasks, $tasks) { 
    164164    log_assert(is_round_id($round_id)); 
    165165 
     
    169169                     db_escape($round_id)); 
    170170    db_query($query); 
    171  
    172     log_print_r($tasks); 
    173     log_print(count($tasks)); 
     171    foreach($old_tasks as $task) { 
     172        // Update parent round cache for old tasks 
     173        task_get_parent_rounds($task, true); 
     174    } 
    174175 
    175176    if (count($tasks) > 0) { 
     
    182183                  VALUES ". implode(', ', $values); 
    183184        db_query($query); 
     185        foreach($tasks as $task) { 
     186            // Update parent round cache for new tasks 
     187            task_get_parent_rounds($task, true); 
     188        } 
    184189    } 
    185190} 
  • trunk/common/db/task.php

    r997 r1010  
    132132 
    133133// Returns list of round ids that include this task 
    134 function task_get_parent_rounds($task_id) { 
     134function task_get_parent_rounds($task_id, $force_no_cache=false) { 
    135135    log_assert(is_task_id($task_id)); 
     136    if (!$force_no_cache) { 
     137        $result = mem_cache_get("task-rounds-by-id:$task_id"); 
     138        if ($result !== false) { 
     139            return $result; 
     140        } 
     141    } 
     142 
    136143    $query = sprintf(" 
    137144        SELECT DISTINCT round_id 
     
    149156    } 
    150157 
     158    mem_cache_set("task-rounds-by-id:$task_id", $idlist); 
    151159    return $idlist; 
    152160} 
Note: See TracChangeset for help on using the changeset viewer.