定制 rollerworks/metadata-doctrine-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rollerworks/metadata-doctrine-cache

最新稳定版本:v0.2

Composer 安装命令:

composer require rollerworks/metadata-doctrine-cache

包简介

Doctrine Cache adapter for the Rollerworks Metadata Component

README 文档

README

Build Status

This package provides a Doctrine Cache adapter for the Rollerworks Metadata Component.

Installation

To install this package, add rollerworks/metadata-doctrine-cache to your composer.json

$ php composer.phar require rollerworks/metadata-doctrine-cache

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

$ php composer update rollerworks/metadata-doctrine-cache

Now, Composer will automatically download all required files, and install them for you.

Usage

require 'vendor/autoload.php';

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\ChainCache;
use Doctrine\Common\Cache\FilesystemCache;
use Rollerworks\Component\Metadata\CacheableMetadataFactory;
use Rollerworks\Component\Metadata\Cache\Validator\AlwaysFreshValidator;
use Rollerworks\Component\Metadata\Cache\ArrayCache;

$cacheDirectory = ...;

// The Doctrine cache library.
$doctrineCache = new ChainCache(
    [
        // Include the ArrayCache as the ChainCache will populate all the previous cache layers.
        // So if the `FilesystemCache` has a match it will populate the faster ArrayCache.
        new ArrayCache(),

        // Saves the cache in the filestem.
        new FilesystemCache($cacheDirectory),
    ]
);

// Rollerworks\Component\Metadata\Cache\CacheProvider
$cache = Rollerworks\Component\Metadata\Driver\Cache\DoctrineCache($doctrineCache);

// Rollerworks\Component\Metadata\Driver\MappingDriver
$driver = ...;

// Rollerworks\Component\Metadata\Cache\FreshnessValidator
$freshnessValidator = ...;

$metadataFactory = new CacheableMetadataFactory($driver, $doctrineCache, $freshnessValidator);

That's it.

Running test

Whenever you open a pull-request tests are already run by Travis-CI.

Tests can be run with PHPUnit, make sure you use the --prefer-source option when running Composer as some classes for testing are not available in the archive package.

统计信息

  • 总下载量: 708
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-17