Reputation: 1454
My project created with Laravel4 and mongoDB.
I created an command with laravel artisan and use this command php artisan taxi:checktrips
in Laravel for check trips. this command in Laravel Runs :
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(),
]);
}
}
}
}
but when i I executed shows :
[MongoException]
zero-length keys are not allowed, did you use $ with double quotes?
how can i fix that to run without any problem?
Upvotes: 1
Views: 81
Reputation: 6539
I think you are trying to save ""
as a key in your db.
Do one thing:-
In your php.ini
,
set mongo.allow_empty_keys to true
May this link will help you.
Upvotes: 1
Reputation: 111869
I think you should make sure you have valid values in $trip_id
.
For example you use:
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
Are you sure you should use index 1
here and not 0
?
Upvotes: 1