openclassrooms/doctrine-cache-extension
最新稳定版本:v1.0.0
Composer 安装命令:
composer require openclassrooms/doctrine-cache-extension
包简介
Library extending doctrine cache capabilities
README 文档
README
The Doctrine Cache extension adds the following features to Doctrine Cache implementation:
- Default lifetime
- Fetch with a namespace
- Save with a namespace
- Cache invalidation through namespace strategy
Installation
The easiest way to install DoctrineCacheExtension is via composer.
Create the following composer.json file and run the php composer.phar install command to install it.
{
"require": {
"openclassrooms/doctrine-cache-extension": "*"
}
}
<?php require 'vendor/autoload.php'; use OpenClassrooms\DoctrineCacheExtension\CacheProviderDecorator; //do things
Usage
Instantiation
OpenClassrooms CacheProviderDecorator needs a Doctrine CacheProvider to be instantiated.
$cacheProvider = new ArrayCache(); $cacheProviderDecorator = new CacheProviderDecorator($cacheProvider);
A factory can be used to accomplish this.
$factory = new CacheProviderDecoratorFactory(); $cacheProvider = $factory->create('array');
Default lifetime
Specify lifetime in the constructor:
$cacheProviderDecorator = new CacheProviderDecorator($cacheProvider, 100); $cacheProviderDecorator->save($id, $data);
Or via the factory:
$cacheProvider = $factory->create('array', 100);
Or specify a default lifetime for all the cache providers:
$factory = new CacheProviderDecoratorFactory(); $factory->setDefaultLifetime(100);
Fetch with namespace
$data = $cacheProviderDecorator->fetchWithNamespace($id, $namespaceId);
Save with namespace
// Namespace and life time can be null $data = $cacheProviderDecorator->saveWithNamespace($id, $data, $namespaceId, $lifeTime);
Cache invalidation
$cacheProviderDecorator->invalidate($namespaceId);
统计信息
- 总下载量: 392.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-09