我的项目是使用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