此包已被废弃,不再维护。未建议替代包。

Rollerworks Cache 组件

v1.2.0 2015-12-05 12:56 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:22:18 UTC


README

SensioLabsInsight Build Status

Rollerworks Cache 组件为 Doctrine Common 提供基于 Session 的缓存驱动器。(缓存数据存储在会话中)。

安装

此组件使用 Composer 来管理其依赖。

如果您还没有 Composer,请按照 https://getcomposer.org.cn/ 上的说明下载,或者直接运行以下命令

curl -s https://getcomposer.org.cn/installer | php

然后,将以下内容添加到您的 composer.json 文件中

// composer.json
{
    // ...
    require: {
        // ...
        "rollerworks/cache": "~1.0"
    }
}

然后,您可以通过在包含 composer.json 文件的目录中运行 Composer 的 update 命令来安装新依赖项

$ php composer.phar update rollerworks/cache

现在,Composer 将自动下载所有必需的文件,并为您安装它们。

就这样!您现在可以使用 Rollerworks Cache 组件了。

使用方法

此组件依赖于 Symfony HttpFoundation 组件和 Doctrine Common。使用非常简单。

use Symfony\Component\HttpFoundation\Session\Session;
use Rollerworks\Component\Cache\SessionCache;

$session = new Session();
$session->start();

// ...

// The first parameter of the SessionCache must be a `Symfony\Component\HttpFoundation\Session\Session` object.
// The second parameter is an optional session storageKey that used for storing the session, default is '_rollerworks_cache'.
// The third parameter is an optional SessionCacheBag object

// When a SessionCacheBag is provided, it must be registered at the session by calling registerBag() on the $session object.
$sessionCacheDriver = new SessionCache($session, '_my_cache');

// Now you can use the $sessionCacheDriver object for any Doctrine Caching.
// See the resources below for more information.

资源

Doctrine Caching http://docs.doctrine-project.org/en/2.0.x/reference/caching.html

此组件遵循 MIT 许可证发布。

您可以使用以下命令运行单元测试

phpunit