original_string: public static function get_record_by_contextlevel($contextlevel, $exception = true) {
          global $DB;
  
          $cache = \cache::make('tool_dataprivacy', 'contextlevel');
          if ($data = $cache->get($contextlevel)) {
              return new static(0, $data);
          }
  
          if (!$record = $DB->get_record(self::TABLE, array('contextlevel' => $contextlevel))) {
              if (!$exception) {
                  return false;
              } else {
                  throw new \dml_missing_record_exception(self::TABLE);
              }
          }
  
          return new static(0, $record);
      }
code: public static function get_record_by_contextlevel($contextlevel, $exception = true) {
          global $DB;
  
          $cache = \cache::make('tool_dataprivacy', 'contextlevel');
          if ($data = $cache->get($contextlevel)) {
              return new static(0, $data);
          }
  
          if (!$record = $DB->get_record(self::TABLE, array('contextlevel' => $contextlevel))) {
              if (!$exception) {
                  return false;
              } else {
                  throw new \dml_missing_record_exception(self::TABLE);
              }
          }
  
          return new static(0, $record);
      }
code_tokens: public static function get_record_by_contextlevel ( $ contextlevel , $ exception = true ) { global $ DB ; $ cache = \ cache :: make ( 'tool_dataprivacy' , 'contextlevel' ) ; if ( $ data = $ cache -> get ( $ contextlevel ) ) { return new static ( 0 , $ data ) ; } if ( ! $ record = $ DB -> get_record ( self :: TABLE , array ( 'contextlevel' => $ contextlevel ) ) ) { if ( ! $ exception ) { return false ; } else { throw new \ dml_missing_record_exception ( self :: TABLE ) ; } } return new static ( 0 , $ record ) ; }
docstring: Returns an instance by contextlevel.
  
  @param mixed $contextlevel
  @param mixed $exception
  @return null
docstring_tokens: Returns an instance by contextlevel .