Skip to content

Commit ee76b41

Browse files
committed
Merge pull request #3 from Nyholm/master
Use factories
2 parents 5003e54 + 95ee39f commit ee76b41

File tree

10 files changed

+158
-433
lines changed

10 files changed

+158
-433
lines changed

.travis.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
language: php
22
php:
3+
- "hhvm"
34
- "7.0"
45
- "5.6"
56
- "5.5"
67

8+
services:
9+
- memcached
10+
- redis-server
11+
712
env:
813
- SYMFONY_VERSION=2.6.*
914
- SYMFONY_VERSION=2.7.*
@@ -16,9 +21,17 @@ matrix:
1621
sudo: false
1722

1823
before_script:
19-
- composer self-update
20-
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
21-
- composer install --dev --prefer-dist --no-interaction
24+
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d
25+
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
26+
- echo "extension=mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
27+
- echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
28+
- echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
29+
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && `php-config --vernum` -ge 70000 ]]; then pecl config-set preferred_state beta; printf "yes\n" | pecl install apcu; else echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
30+
- composer self-update
31+
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
32+
- composer install --dev --prefer-dist --no-interaction
33+
# must be set after composer to avoid issue with autoloading
34+
- echo "apc.enable_cli=On" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
2235

2336
script:
2437
- php vendor/bin/phpunit

README.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Adapter Bundle
22
[![Build Status](https://travis-ci.org/php-cache/adapter-bundle.png?branch=master)](https://travis-ci.org/php-cache/adapter-bundle)
33

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 compliant.
4+
This bundle helps you configurate and register PSR-6 cache services.
65

76
### To Install
87

@@ -25,51 +24,32 @@ $bundles(
2524
### Configuration
2625

2726
```yaml
28-
cache_adapter_doctrine:
27+
cache_adapter:
2928
providers:
3029
acme_memcached:
31-
type: memcached
32-
persistent: true # Boolean or persistent_id
33-
namespace: mc
34-
hosts:
35-
- { host: localhost, port: 11211 }
36-
acme_redis:
37-
type: redis
38-
hosts:
39-
main:
40-
host: 127.0.0.1
41-
port: 6379
42-
acme_file_system_cache:
43-
type: file_system
44-
extension: '.fsc'
45-
directory: '%kernel.root_dir%/var/storage/fs_cache/'
46-
acme_php_file_cache:
47-
type: php_file
48-
extension: '.cache'
49-
directory: '%kernel.root_dir%/var/storage/'
50-
acme_array_cache:
51-
type: array
52-
acme_apc_cache:
53-
type: apc
54-
namespace: my_ns
30+
factory: cache.factory.memcached
31+
options:
32+
persistent: true # Boolean or persistent_id
33+
namespace: mc
34+
hosts:
35+
- { host: localhost, port: 11211 }
5536
```
5637
5738
### Usage
5839
59-
When using a configuration like below, you will get a service with the id `cache.provider.acme_apc_cache`.
40+
When using a configuration like below, you will get a service with the id `cache.provider.acme_redis`.
6041
```yaml
61-
cache_adapter_doctrine:
42+
cache_adapter:
6243
providers:
63-
acme_apc_cache:
64-
type: apc
65-
namespace: my_ns
44+
acme_redis:
45+
factory: cache.factory.redis
6646
```
6747

6848
Use the new service as any PSR-6 cache.
6949

7050
``` php
7151
/** @var CacheItemPoolInterface $cache */
72-
$cache = $this->container->get('cache.provider.acme_apc_cache');
52+
$cache = $this->container->get('cache.provider.acme_redis');
7353
// Or
7454
$cache = $this->container->get('cache'); // This is either the `default` provider, or the first provider in the config
7555

@@ -80,4 +60,3 @@ $item->expiresAfter(3600);
8060
$cache->save($item);
8161
```
8262

83-
[DoctrineAdapter]: https://github.com/php-cache/doctrine-adapter

0 commit comments

Comments
 (0)