original_string: protected static function set_backup_ids_cached($restoreid, $itemname, $itemid, $extrarecord) {
          global $DB;
  
          $key = "$itemid $itemname $restoreid";
  
          $record = array(
              'backupid' => $restoreid,
              'itemname' => $itemname,
              'itemid'   => $itemid,
          );
  
          // If record is not cached then add one.
          if (!isset(self::$backupidsexist[$key])) {
              // If we have this record in db, then just update this.
              if ($existingrecord = $DB->get_record('backup_ids_temp', $record)) {
                  self::$backupidsexist[$key] = $existingrecord->id;
                  self::$backupidsexistsize--;
                  self::update_backup_cached_record($record, $extrarecord, $key, $existingrecord);
              } else {
                  // Add new record to cache and db.
                  $recorddefault = array (
                      'newitemid' => 0,
                      'parentitemid' => null,
                      'info' => null);
                  $record = array_merge($record, $recorddefault, $extrarecord);
                  $record['id'] = $DB->insert_record('backup_ids_temp', $record);
                  self::$backupidsexist[$key] = $record['id'];
                  self::$backupidsexistsize--;
                  if (self::$backupidscachesize > 0) {
                      // Cache new records if we haven't got many yet.
                      self::$backupidscache[$key] = (object) $record;
                      self::$backupidscachesize--;
                  }
              }
          } else {
              self::update_backup_cached_record($record, $extrarecord, $key);
          }
      }
code: protected static function set_backup_ids_cached($restoreid, $itemname, $itemid, $extrarecord) {
          global $DB;
  
          $key = "$itemid $itemname $restoreid";
  
          $record = array(
              'backupid' => $restoreid,
              'itemname' => $itemname,
              'itemid'   => $itemid,
          );
  
          // If record is not cached then add one.
          if (!isset(self::$backupidsexist[$key])) {
              // If we have this record in db, then just update this.
              if ($existingrecord = $DB->get_record('backup_ids_temp', $record)) {
                  self::$backupidsexist[$key] = $existingrecord->id;
                  self::$backupidsexistsize--;
                  self::update_backup_cached_record($record, $extrarecord, $key, $existingrecord);
              } else {
                  // Add new record to cache and db.
                  $recorddefault = array (
                      'newitemid' => 0,
                      'parentitemid' => null,
                      'info' => null);
                  $record = array_merge($record, $recorddefault, $extrarecord);
                  $record['id'] = $DB->insert_record('backup_ids_temp', $record);
                  self::$backupidsexist[$key] = $record['id'];
                  self::$backupidsexistsize--;
                  if (self::$backupidscachesize > 0) {
                      // Cache new records if we haven't got many yet.
                      self::$backupidscache[$key] = (object) $record;
                      self::$backupidscachesize--;
                  }
              }
          } else {
              self::update_backup_cached_record($record, $extrarecord, $key);
          }
      }
code_tokens: protected static function set_backup_ids_cached ( $ restoreid , $ itemname , $ itemid , $ extrarecord ) { global $ DB ; $ key = "$itemid $itemname $restoreid" ; $ record = array ( 'backupid' => $ restoreid , 'itemname' => $ itemname , 'itemid' => $ itemid , ) ; // If record is not cached then add one. if ( ! isset ( self :: $ backupidsexist [ $ key ] ) ) { // If we have this record in db, then just update this. if ( $ existingrecord = $ DB -> get_record ( 'backup_ids_temp' , $ record ) ) { self :: $ backupidsexist [ $ key ] = $ existingrecord -> id ; self :: $ backupidsexistsize -- ; self :: update_backup_cached_record ( $ record , $ extrarecord , $ key , $ existingrecord ) ; } else { // Add new record to cache and db. $ recorddefault = array ( 'newitemid' => 0 , 'parentitemid' => null , 'info' => null ) ; $ record = array_merge ( $ record , $ recorddefault , $ extrarecord ) ; $ record [ 'id' ] = $ DB -> insert_record ( 'backup_ids_temp' , $ record ) ; self :: $ backupidsexist [ $ key ] = $ record [ 'id' ] ; self :: $ backupidsexistsize -- ; if ( self :: $ backupidscachesize > 0 ) { // Cache new records if we haven't got many yet. self :: $ backupidscache [ $ key ] = ( object ) $ record ; self :: $ backupidscachesize -- ; } } } else { self :: update_backup_cached_record ( $ record , $ extrarecord , $ key ) ; } }
docstring: Cache backup ids'
  
  @param int $restoreid id of backup
  @param string $itemname name of the item
  @param int $itemid id of item
  @param array $extrarecord extra record which needs to be updated
  @return void
  @todo MDL-25290 replace static BACKUP_IDS_* with MUC code
docstring_tokens: Cache backup ids