This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Loop { | |
public static void main(String[] args) | |
{ | |
Integer total = 500000000; | |
Integer chunk = 50000000; | |
Integer i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"_id" : ObjectId("550d2255d2ea07ae148b456d"), | |
"comments" : [ | |
{ | |
"_id" : ObjectId("550d2255d2ea07ae148b4567"), | |
"title" : "salam comment 1", | |
"body" : "salam comment matn 1", | |
"cid" : 1 | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Bigsinoos\Helpers; | |
class TreeFilter { | |
/** | |
* Get only some variables of a tow-level nested array | |
* | |
* @param $filterable | |
* @param array $keep | |
* @return array | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array(2) { | |
[0] array(7) { | |
["phone_number"] 91212345678 | |
["creator_id"] 53 | |
["description"] "number 1" | |
["priority"] 0 | |
["shared"] true | |
["phones"] array(1) { | |
["phone_number"] 91212345678 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach($collection as $key => $item){ | |
if(is_array($item)){ | |
foreach($item as $tree => $treeItem){ | |
if($tree != 'phones'){ | |
unset($item[$tree]) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Session { | |
public function __construct(StorageInterface $storage) | |
{ | |
$this->storage = $storage; | |
} | |
} | |
class RedisStorage implments StorageInterface {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JobManagerWrapper { | |
public function __call($method, $args) | |
{ | |
$instance = App::make('JobManager'); | |
return call_user_func_array([$instance, $job], $args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function daemon($connectionName, $queue = null, $delay = 0, $memory = 128, $sleep = 3, $maxTries = 0) | |
{ | |
$lastRestart = $this->getTimestampOfLastQueueRestart(); | |
while (true) | |
{ | |
if ($this->daemonShouldRun()) | |
{ | |
$this->runNextJobForDaemon( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Machine: | |
Core i3 CPU 3Ghz | |
RAM 6GB | |
Hard Disk , SataII ~7000 rpm | |
Logic: | |
Laravel has queue:work in daemon and non-daemon mode, the non-daemon mode takes a job from Queue processes it and then the framework is shut down. | |
Test logic relies on multi processing + async request using non-daemon mode, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function __construct (\GuzzleHttp\Client $client) | |
{ | |
$this->client = $client; | |
} | |
public function asyncReqs () | |
{ | |
$requests = []; |