-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.php
29 lines (22 loc) · 754 Bytes
/
demo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
* Shared data PHP extension
*
* @copyright Copyright 2021, Lisachenko Alexander <lisachenko.it@gmail.com>
*
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/
use Lisachenko\SharedData\Extension;
use ZEngine\Core;
include __DIR__ . '/vendor/autoload.php';
Core::init();
$extension = Extension::create('shared-data', 'unsigned int[10]');
if (!$extension->isModuleRegistered()) {
$extension->register();
$extension->startup();
}
$data = $extension->getGlobals();
$index = mt_rand(0, 9); // If you have several workers, you should use worker pid to avoid race conditions
$data[$index] = $data[$index] + 1; // We are increasing global counter by one
var_dump($data);