Skip to content

Commit

Permalink
Adding doctrine cache to the suggest directive in composer.json to in…
Browse files Browse the repository at this point in the history
…dicate cache support, also added an example of how this could be used.
  • Loading branch information
wtfzdotnet committed Mar 1, 2014
1 parent 2c19c97 commit 3de15b1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"guzzle/guzzle": ">=0.7"
},
"require-dev": {
"phpunit/phpunit": ">=3.7"
"phpunit/phpunit": ">=3.7",
"doctrine/cache": ">=1.3.0"
},
"suggest": {
"doctrine/cache": "This library is required if you want to make use of caching features."
},
"autoload": {
"psr-0": { "Tmdb\\": "lib/" }
Expand Down
32 changes: 32 additions & 0 deletions examples/movies/model/cache/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
require_once '../../../../vendor/autoload.php';
require_once '../../../../apikey.php';

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$cachePlugin = new \Guzzle\Plugin\Cache\CachePlugin(array(
'storage' => new \Guzzle\Plugin\Cache\DefaultCacheStorage(
new \Guzzle\Cache\DoctrineCacheAdapter(
new \Doctrine\Common\Cache\FilesystemCache('/tmp/_php-tmdb-api')
)
)
));

$client->getHttpClient()->addSubscriber($cachePlugin);

$repository = new \Tmdb\Repository\MovieRepository($client);
$movie = $repository->load(87421);

var_dump($movie);

0 comments on commit 3de15b1

Please sign in to comment.