public function compute($command)
 {
     $context = "Platform: " . stack_connection_helper::get_platform() . "\n";
     $context .= "Maxima shell command: " . $this->command . "\n";
     $context .= "Maxima initial command: " . $this->initcommand . "\n";
     $context .= "Maxima timeout: " . $this->timeout;
     $this->debug->log('Context used', $context);
     $this->debug->log('Maxima command', $command);
     $rawresult = $this->call_maxima($command);
     $this->debug->log('CAS result', $rawresult);
     $unpackedresult = $this->unpack_raw_result($rawresult);
     $this->debug->log('Unpacked result as', print_r($unpackedresult, true));
     if (!stack_connection_helper::check_stackmaxima_version($unpackedresult)) {
         stack_connection_helper::warn_about_version_mismatch($this->debug);
     }
     return $unpackedresult;
 }
 public function compute($command)
 {
     $cached = $this->get_cached_result($command);
     if ($cached->result) {
         $this->debug->log('Maxima command', $command);
         $this->debug->log('Unpacked result found in the DB cache', print_r($cached->result, true));
         if (!stack_connection_helper::check_stackmaxima_version($cached->result)) {
             stack_connection_helper::warn_about_version_mismatch($this->debug);
             // We could consider automatically purging the cache here.
         }
         return $cached->result;
     }
     $this->debug->log('Maxima command not found in the cache. Using the raw connection.');
     $result = $this->rawconnection->compute($command);
     // Only add to the cache if we didn't timeout!
     if (!stack_connection_helper::did_cas_timeout($result)) {
         $this->add_to_cache($command, $result, $cached->key);
     }
     return $result;
 }