11# Doctrine Adapter Bundle
2+ [ ![ Build Status] ( https://travis-ci.org/php-cache/doctrine-adapter-bundle.png?branch=master )] ( https://travis-ci.org/php-cache/doctrine-adapter-bundle )
23
3- This bundle registers PSR6 cache services that wraps the doctrine cache.
4+ This bundle helps you configurate and register PSR-6 cache services. The bundle uses Doctrine as cache implementation
5+ with help from [ DoctrineAdapter] to make it PSR-6 complient.
46
5- ## Configuration and usage
7+ ### To Install
68
7- ``` yaml
9+ Run the following in your project root, assuming you have composer set up for your project
10+ ``` sh
11+ composer require cache/doctrine-adapter-bundle
12+ ```
13+
14+ Add the bundle to app/AppKernel.php
15+
16+ ``` php
17+ $bundles(
18+ // ...
19+ new Cache\Adapter\DoctrineAdapterBundle\DoctrineAdapterBundle(),
20+ // ...
21+ );
22+ ```
823
24+
25+ ### Configuration
26+
27+ ``` yaml
928cache_adapter_doctrine :
1029 providers :
1130 acme_file_system_cache :
@@ -17,12 +36,28 @@ cache_adapter_doctrine:
1736 namespace : my_ns
1837` ` `
1938
20- ` ` ` php
39+ ### Usage
2140
22- /** @var CacheItemPoolInterface $cacheProvider */
23- $cacheProvider = $this->container->get('cache.provider.acme_apc_cache');
41+ When using a configuration like below, you will get an service with the id ` cache/doctrine-adapter-bundle`.
42+ ` ` ` yaml
43+ cache_adapter_doctrine:
44+ providers:
45+ acme_apc_cache:
46+ type: apc
47+ namespace: my_ns
48+ ` ` `
49+
50+ Use the new service as any PSR-6 cache.
51+
52+ ` ` ` php
53+ /** @var CacheItemPoolInterface $cache */
54+ $cache = $this->container->get('cache/doctrine-adapter-bundle');
2455
2556/** @var CacheItemInterface $item */
26- $item = $cacheProvider->getItem('cache-key');
57+ $item = $cache->getItem('cache-key');
58+ $item->set('foobar');
59+ $item->expiresAfter(3600);
60+ $cache->save($item);
61+ ` ` `
2762
28- ```
63+ [DoctrineAdapter] : https://github.com/php-cache/doctrine-adapter
0 commit comments