1- # Doctrine PSR-6 adapter
2- [ ![ Build Status ] ( https://travis-ci. org/php- cache/doctrine-adapter.svg?branch=master )] ( https://travis-ci .org/php- cache/doctrine-adapter ) [ ![ codecov.io] ( https://codecov.io/github/php-cache/doctrine-adapter/coverage.svg?branch=master )] ( https://codecov.io/github/php-cache/doctrine-adapter?branch=master ) [ ![ SensioLabsInsight ] ( https://insight.sensiolabs.com/projects/1ac09139-8edd-41a9-84ab-3d84791a2659/mini.png ) ]( https://insight.sensiolabs.com/projects/1ac09139-8edd-41a9-84ab-3d84791a2659 )
1+ # Doctrine PSR-6 Cache pool
2+ [ ![ Latest Stable Version ] ( https://poser.pugx. org/cache/doctrine-adapter/v/stable )] ( https://packagist .org/packages/ cache/doctrine-adapter ) [ ![ codecov.io] ( https://codecov.io/github/php-cache/doctrine-adapter/coverage.svg?branch=master )] ( https://codecov.io/github/php-cache/doctrine-adapter?branch=master ) [ ![ Build Status ] ( https://travis-ci.org/php-cache/doctrine-adapter.svg?branch=master )] ( https://travis-ci.org/php-cache/doctrine-adapter ) [ ![ Total Downloads ] ( https://poser.pugx.org/cache/doctrine-adapter/downloads )] ( https://packagist.org/packages/cache/doctrine-adapter ) [ ![ Monthly Downloads ] ( https://poser.pugx.org/cache/doctrine-adapter/d/monthly.png )] ( https://packagist.org/packages/cache/doctrine-adapter ) [ ![ Software License ] ( https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square )] ( LICENSE )
33
4- This is a implementation for the PSR-6 that wraps the Doctrine cache. This implementation supports tags.
4+ This is a PSR-6 cache implementation using Doctrine. It is a part of the PHP Cache organisation. To read about
5+ features like tagging and hierarchy support please read the shared documentation at [ www.php-cache.com ] ( http://www.php-cache.com ) .
56
6- If you want to use this library with Symfony you may be intrerested in
7- [ Doctrine Adapter Bundle ] ( https://github.com/php-cache/doctrine-adapter-bundle ) .
7+ This is a PSR-6 to Doctrine bridge. If you are interested in a Doctrine to PSR-6 bridge you should have a look at
8+ [ PSR-6 Doctrine Bridge ] ( https://github.com/php-cache/doctrine-bridge ) .
89
9- ## To Install
10+ ### Install
1011
11- Run the following in your project root, assuming you have composer set up for your project
12- ``` sh
12+ ``` bash
1313composer require cache/doctrine-adapter
1414```
1515
@@ -19,42 +19,14 @@ composer require cache/doctrine-adapter
1919use Doctrine\Common\Cache\MemcachedCache;
2020use Cache\Doctrine\CachePool;
2121
22- // Create a instance of Doctrine's MemcachedCache
22+
2323$memcached = new \Memcached();
2424$memcached->addServer('localhost', 11211);
25+
26+ // Create a instance of Doctrine's MemcachedCache
2527$doctrineCache = new MemcachedCache();
2628$doctrineCache->setMemcached($memcached);
2729
2830// Wrap Doctrine's cache with the PSR-6 adapter
2931$pool = new CachePool($doctrineCache);
30-
31- /** @var CacheItemInterface $item */
32- $item = $pool->getItem('key');
33- ```
34-
35- ## Tagging
36-
37- The ` CachePool ` implements ` Cache\Taggable\TaggablePoolInterface ` from [ Taggable Cache] ( https://github.com/php-cache/taggable-cache ) .
38- Below is an example of how you could use tags:
39-
40- ``` php
41-
42- $item = $pool->getItem('tobias', ['person']);
43- $item->set('foobar');
44- $pool->save($item);
45-
46- $item = $pool->getItem('aaron', ['person', 'developer']);
47- $item->set('foobar');
48- $pool->save($item);
49-
50- $pool->getItem('tobias', ['person'])->isHit(); // true
51- $pool->getItem('aaron', ['person', 'developer'])->isHit(); // true
52-
53- // Clear all cache items tagged with 'developer'
54- $pool->clear(['developer']);
55-
56- $pool->getItem('tobias', ['person'])->isHit(); // true
57- $pool->getItem('aaron', ['person', 'developer'])->isHit(); // false
5832```
59-
60- See more example and understand how you use tags here: https://github.com/php-cache/taggable-cache
0 commit comments