Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine cache #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Guzzle 3 compatibility continues in the [`1.0`](https://github.com/commerceguys/
- Supports refresh tokens (stores them and uses them to get new access tokens).
- Handles token expiration (acquires new tokens and retries failed requests).

- You can now optionally deal with token persistence with doctrine cache. Just require doctrine/cache , instantiate a cache implementation.
tokens are now cached for a lifetime corresponding to their expire value.

## Running the tests

First make sure you have all the dependencies in place by running `composer install --prefer-dist`, then simply run `./bin/phpunit`.
Expand Down Expand Up @@ -50,6 +53,11 @@ $refreshToken = new RefreshToken($oauth2Client, $config);

$oauth2 = new Oauth2Subscriber($token, $refreshToken);


$redis_client = new Predis\Client();
$doctrine_cache = new \Doctrine\Common\Cache\PredisCache($redis_client);
$oauth2->setCache($doctrine_cache);

$client = new Client([
'defaults' => [
'auth' => 'oauth2',
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
}
},
"require-dev": {
"phpunit/phpunit": "~4.5"
"phpunit/phpunit": "~4.5",
"doctrine/cache": "~1.3"
},
"suggest": {
"doctrine/cache": "Allow token persistence in doctrine cache"
},
"autoload-dev": {
"psr-4": {
Expand All @@ -28,6 +32,9 @@
},
{
"name": "Patrick Dawkins"
},
{
"name": "Xavier Lembo"
}
],
"config": {
Expand Down
Loading