PHP 8.4.1 Released!

SyncSharedMemory::__construct

(PECL sync >= 1.1.0)

SyncSharedMemory::__constructConstructs a new SyncSharedMemory object

Опис

public SyncSharedMemory::__construct(string $name, int $size)

Constructs a named shared memory object.

Параметри

name

The name of the shared memory object.

Зауваження:

If the name already exists, it must be able to be opened by the current user that the process is running as or an exception will be thrown with a meaningless error message.

size

The size, in bytes, of shared memory to reserve.

Зауваження:

The amount of memory cannot be resized later. Request sufficient storage up front.

Значення, що повертаються

The new SyncSharedMemory object.

Помилки/виключення

An exception is thrown if the shared memory object cannot be created or opened.

Приклади

Приклад #1 SyncSharedMemory::__construct() example

<?php
// You will probably need to protect shared memory with other synchronization objects.
// Shared memory goes away when the last reference to it disappears.
$mem = new SyncSharedMemory("AppReportName", 1024);
if (
$mem->first())
{
// Do first time initialization work here.
}

$result = $mem->write(json_encode(array("name" => "my_report.txt")));
?>

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top