我的項目是使用Laravel4和mongoDB創建的。 我使用laravel artisan創建了一個命令,並在Laravel中使用此命令php artisan taxi:checktrips
進行檢查。在Laravel運行此命令:laravel4中的PHP artisan命令運行錯誤
public function schedule(Schedulable $scheduler)
{
return $scheduler->everyMinutes(.06);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
while (true) {
try {
sleep(2);
foreach ($this->redis->keys('trip_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if ($this->driver->closest($trip_id)) {
echo 'Closest, Add trip_temp_id Redis';
$this->redis->set('trip_temp_id|'.$trip_id,
(int) $this->redis->get($key));
Log::importRedis('trip_temp_id|'.$trip_id, $trip_id);
}
echo "{$trip_id}, Deleted Redis";
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
}
foreach ($this->redis->keys('trip_temp_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if (\Carbon\Carbon::now()->timestamp > (int) $this->redis->get($key)) {
echo 'Deleting Temp Redis';
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
$this->driver->rejectTrip($trip_id);
}
}
} catch (\Exception $e) {
Log::errorLog([
'file' => $e->getFile(),
'line' => $e->getLine(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
'trace' => $e->getTrace(),
'trace_string' => $e->getTraceAsString(),
'previous' => $e->getPrevious(),
]);
}
}
}
}
但是當我執行我顯示:
[MongoException]
zero-length keys are not allowed, did you use $ with double quotes?
如何解決,要沒有任何問題上運行?
如果我把'0'。你認爲問題會解決? – Amirali
@Amiraliroshanaei我真的不知道你在Redis中的確切位置,以及你在'$ trip_id'中得到的結果 - 你應該逐步驗證你在$ trip_id中實際獲得的數據是 –
我使用'568cceddbc919a427e8b4764'這樣的mongoid和在redis中:我的項目驅動程序存在於隊列中,並且使用redis,我接近乘客 – Amirali