adammbalogh/key-value-store-shared-memory

通过 PHP 共享内存模块实现键值共享内存存储。

0.5.1 2014-10-20 19:28 UTC

This package is auto-updated.

Last update: 2024-08-29 01:51:19 UTC


README

Author Build Status Coverage Status Quality Score Software License Packagist Version Total Downloads

SensioLabsInsight

描述

此库提供了一层键值共享内存存储的接口。

它使用了 PHP 共享内存模块

查看 抽象库 了解其他适配器和 API。

安装

通过 composer 安装。

{
    "require": {
        "adammbalogh/key-value-store-shared-memory": "@stable"
    }
}

提示:您应该浏览 adammbalogh/key-value-store-shared-memory 页面,选择要使用的稳定版本,避免使用 @stable 元数据约束。

用法

<?php
use AdammBalogh\KeyValueStore\KeyValueStore;
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter as Adapter;

$tmpFileName = tempnam('/tmp', 'KVS');
$shmResource = shm_attach(ftok($tmpFileName, 'a'));
if ( ! $shmResource) {
    die('Unable to create the shared memory segment');
}

$adapter = new Adapter($shmResource);

$kvs = new KeyValueStore($adapter);

$kvs->set('sample_key', 'Sample value');
$kvs->get('sample_key');
$kvs->delete('sample_key');

API

请访问抽象库中的 API 链接。

工具集

支持

Support with Gittip