vsitnikov/php-shared-memory

PHP共享内存库

dev-master 2019-11-08 12:47 UTC

This package is not auto-updated.

Last update: 2024-09-21 12:45:32 UTC


README

注意!该项目处于开发阶段,请勿使用,一切都可能发生完全的变化。

初始化

use vsitnikov\SharedMemory\AbstractSharedMemoryClient as mem;
require_once "../vendor/autoload.php";

$file = "/path/to/exists/file";

//  A simple option, only the file is indicated, if the data is already there, they will be saved, as well as locks
mem::init(["memory_key" => $file]);

//  Same
mem::init(["memory_key" => $file, "init_rule" => mem::INIT_DATA_SAFE]);

//  Forced deletion of all data and unlocking
mem::init(["memory_key" => $file, "init_rule" => mem::INIT_DATA_CLEAN]);

//  Saving all data, regardless of whether something is saved or not. Attention! Reading data from an uninitialized repository will result in an error
mem::init(["memory_key" => $file, "init_rule" => mem::INIT_DATA_IGNORE]);

设置值

mem::set("/path/to/key", "value");

获取值

# Get value
mem::get("/path/to/key");

# Get dir
mem::get("/path/to");

# Get dir recursive
mem::get("/path");