Skip to content

Commit b27eddd

Browse files
committed
Merge pull request #45 from php-cache/docs
Updated readme, removed Doctrine cache bundle
2 parents acdeb35 + 5d0cd1a commit b27eddd

File tree

1 file changed

+10
-192
lines changed

1 file changed

+10
-192
lines changed

README.md

Lines changed: 10 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -1,212 +1,30 @@
1-
# PHP-Cache cache-bundle
2-
[![Build Status](https://travis-ci.org/php-cache/cache-bundle.png?branch=master)](https://travis-ci.org/php-cache/cache-bundle) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/ea12a1b3-09c9-4f0a-9a2c-63d72b47db5a/mini.png)](https://insight.sensiolabs.com/projects/ea12a1b3-09c9-4f0a-9a2c-63d72b47db5a)
3-
4-
#### Cache Bundle for Symfony 2.6 and above
1+
# PSR-6 Cache bundle
2+
[![Latest Stable Version](https://poser.pugx.org/cache/cache-bundle/v/stable)](https://packagist.org/packages/cache/cache-bundle) [![codecov.io](https://codecov.io/github/php-cache/cache-bundle/coverage.svg?branch=master)](https://codecov.io/github/php-cache/cache-bundle?branch=master) [![Build Status](https://travis-ci.org/php-cache/cache-bundle.svg?branch=master)](https://travis-ci.org/php-cache/cache-bundle) [![Total Downloads](https://poser.pugx.org/cache/cache-bundle/downloads)](https://packagist.org/packages/cache/cache-bundle) [![Monthly Downloads](https://poser.pugx.org/cache/cache-bundle/d/monthly.png)](https://packagist.org/packages/cache/cache-bundle) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a/mini.png)](https://insight.sensiolabs.com/projects/21963379-2b15-4cc4-bdf6-0f98aa292f8a) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
53

64
This is a Symfony bundle that lets you you integrate your PSR-6 compliant cache service with the framework.
75
It lets you cache your sessions, routes and Doctrine results and metadata. It also provides an integration with the
8-
debug toolbar.
9-
10-
11-
#### Requirements
6+
debug toolbar. This bundle does not contain any pool implementation nor does it help you register cache pool services.
7+
You maybe interested in [AdapterBundle](https://github.com/php-cache/adapter-bundle) which will help you configure and
8+
register PSR-6 cache pools as services.
129

13-
- PHP >= 5.5, < 7.1
14-
- Symfony >= 2.6, ^3.0
15-
- [Composer](http://getcomposer.org)
10+
This bundle is a part of the PHP Cache organisation. To read about features like tagging and hierarchy support please
11+
read the shared documentation at [www.php-cache.com](http://www.php-cache.com).
1612

1713
### To Install
1814

19-
You need to install and enable this bundle and also a PSR-6 cache implementation. In the example below we use the
20-
[DoctrineAdapterBundle].
21-
2215
Run the following in your project root, assuming you have composer set up for your project
2316
```sh
24-
composer require cache/cache-bundle cache/doctrine-adapter-bundle
17+
composer require cache/cache-bundle
2518
```
2619

27-
Add the bundles to app/AppKernel.php
20+
Add the bundle to app/AppKernel.php
2821

2922
```php
3023
$bundles(
3124
// ...
3225
new Cache\CacheBundle\CacheBundle(),
33-
new Cache\Adapter\DoctrineAdapterBundle\DoctrineAdapterBundle(),
3426
// ...
3527
);
3628
```
3729

38-
To see all the config options, run `php app/console config:dump-reference cache` to view the config settings
39-
40-
41-
#### A word on the cache implementation
42-
43-
This bundle does not register any cache services for you. This is done by [DoctrineAdapterBundle] you should look
44-
at its documentation to see how you configure that bundle. Below in an example configuration:
45-
46-
```yml
47-
cache_adapter_doctrine:
48-
providers:
49-
acme_redis_cache:
50-
type: redis
51-
database: 'foo'
52-
acme_apc_cache:
53-
type: apc
54-
namespace: my_ns
55-
```
56-
57-
### Configuration
58-
59-
#### Doctrine
60-
61-
This bundle allows you to use its services for Doctrine's caching methods of metadata, result, and query. To use this
62-
feature you need to install the [DoctrineBridge].
63-
64-
```sh
65-
composer require cache/psr-6-doctrine-bridge
66-
```
67-
68-
69-
If you want Doctrine to use this as the result and query cache, you need this configuration:
70-
71-
```yml
72-
cache:
73-
doctrine:
74-
enabled: true
75-
metadata:
76-
service_id: cache.provider.acme_redis_cache
77-
entity_managers: [ default ] # the name of your entity_manager connection
78-
document_managers: [ default ] # the name of your document_manager connection
79-
result:
80-
service_id: cache.provider.acme_redis_cache
81-
entity_managers: [ default, read ] # you may specify multiple entity_managers
82-
query:
83-
service_id: cache.provider.acme_redis_cache
84-
entity_managers: [ default ]
85-
```
86-
87-
To use this with Doctrine's entity manager, just make sure you have `useResultCache` and/or `useQueryCache` set to true.
88-
89-
```php
90-
$em = $this->get('doctrine.orm.entity_manager');
91-
$q = $em->('SELECT u.* FROM Acme\User u');
92-
$q->useResultCache(true, 3600);
93-
$result = $q->getResult();
94-
95-
```
96-
97-
#### Session
98-
99-
This bundle even allows you to store your session data in one of your cache clusters. To enable:
100-
101-
```yml
102-
cache:
103-
session:
104-
enabled: true
105-
service_id: cache.provider.acme_redis_cache
106-
ttl: 7200
107-
```
108-
109-
#### Router
110-
111-
This bundle also provides router caching, to help speed that section up. To enable:
112-
113-
```yml
114-
cache:
115-
router:
116-
enabled: true
117-
service_id: cache.provider.acme_redis_cache
118-
ttl: 86400
119-
```
120-
121-
If you change any of your routes, you will need to clear the cache. If you use a cache implementation that supports
122-
tagging (implements [TaggablePoolInterface](https://github.com/php-cache/taggable-cache/blob/master/src/TaggablePoolInterface.php))
123-
you can clear the cache tagged with `routing`.
124-
125-
The routing cache will make the route lookup more performant when your application have many routes, especially many
126-
dynamic routes. If you just have a few routes your performance will actually be worse enabling this.
127-
Use [Blackfire](https://blackfire.io/) to profile your application to see if you should enable routing cache or not.
128-
129-
130-
#### Logging
131-
132-
If you want to log all the interaction with the cache you may do so with the following configuration.
133-
134-
```yml
135-
cache:
136-
logging:
137-
enabled: true
138-
logger: 'logger' # Default service id to use for logging
139-
level: 'info' # Default logging level
140-
```
141-
142-
#### Annotation
143-
144-
To use a PSR-6 cache for your annotations, use the following confguration.
145-
146-
```yml
147-
cache:
148-
annotation:
149-
enabled: true
150-
service_id: cache.provider.acme_apc_cache
151-
152-
framwork:
153-
annotations:
154-
cache: cache.service.annotation
155-
```
156-
157-
#### Serialization
158-
159-
To use a PSR-6 cache for the serialzer, use the following confguration.
160-
161-
```yml
162-
cache:
163-
serializer:
164-
enabled: true
165-
service_id: cache.provider.acme_apc_cache
166-
167-
framwork:
168-
serializer:
169-
cache: cache.service.serializer
170-
```
171-
172-
#### Validation
173-
174-
To use a PSR-6 cache for the validation, use the following confguration.
175-
176-
```yml
177-
cache:
178-
validation:
179-
enabled: true
180-
service_id: cache.provider.acme_apc_cache
181-
182-
framwork:
183-
validation:
184-
cache: cache.service.validation
185-
```
186-
187-
188-
### Clearing the cache
189-
190-
If you want to clear the cache you can run the following commands.
191-
192-
```sh
193-
php app/console cache:flush session
194-
php app/console cache:flush router
195-
php app/console cache:flush doctrine
196-
197-
echo "Or you could run:"
198-
php app/console cache:flush all
199-
200-
echo "Run the following command to see all your options:"
201-
php app/console cache:flush help
202-
```
203-
204-
*Caution: If you are using a implementation that does not support tagging you will clear all with any of the above commands.*
205-
206-
### Need Help?
207-
208-
Create an issue if you've found a bug, or ping one of us on twitter: @aequasi or @TobiasNyholm
209-
210-
211-
[DoctrineAdapterBundle]:https://github.com/php-cache/doctrine-adapter-bundle
212-
[DoctrineBridge]:https://github.com/php-cache/doctrine-bridge
30+
Read the documentation at [www.php-cache.com/symfony/cache-bundle](http://www.php-cache.com/en/latest/symfony/cache-bundle/).

0 commit comments

Comments
 (0)