Many changes.
This commit is contained in:
parent
dc02826079
commit
13ad2b0ef8
15 changed files with 148 additions and 178 deletions
59
tests/ExampleClass.php
Normal file
59
tests/ExampleClass.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
class ExampleClass
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* ExampleClass constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value in the data array
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set(string $key, mixed $value): void
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a value from the data array
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $key): mixed
|
||||
{
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a key exists in the data array
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $key): bool
|
||||
{
|
||||
return isset($this->data[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function clear(): void
|
||||
{
|
||||
$this->data = [];
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ use TamerLib\tm;
|
|||
|
||||
// Start as client mode, if no configuration is passed on then
|
||||
// Tamer will spawn its own Redis server and use it.
|
||||
tm::initalize(TamerMode::CLIENT);
|
||||
tm::initialize(TamerMode::CLIENT);
|
||||
tm::createWorker(20, __DIR__ . DIRECTORY_SEPARATOR . 'worker.php');
|
||||
|
||||
$total_sleep = 0;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import('net.nosial.tamerlib');
|
||||
|
||||
// Initialize as a worker, will fail if the process is executed directly
|
||||
\TamerLib\tm::initalize(\TamerLib\Enums\TamerMode::WORKER);
|
||||
\TamerLib\tm::initialize(\TamerLib\Enums\TamerMode::WORKER);
|
||||
|
||||
// Callback Examples
|
||||
\TamerLib\tm::addFunction('sleep', function($sleep_time){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue