Skip to content

Commit a63dfa7

Browse files
CopilotKevinrob
andauthored
Drop doctrine/cache support (fixes #155, #188) (#201)
* Initial plan * Remove doctrine/cache dependency and related code Co-authored-by: Kevinrob <4509277+Kevinrob@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Kevinrob <4509277+Kevinrob@users.noreply.github.com>
1 parent 8c04f9a commit a63dfa7

File tree

6 files changed

+14
-232
lines changed

6 files changed

+14
-232
lines changed

README.md

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ A HTTP Cache for [Guzzle](https://github.com/guzzle/guzzle) 6+. It's a simple Mi
1212
- Assured compatibility with PSR-7
1313

1414
## Built-in storage interfaces
15-
- [Doctrine cache](https://github.com/doctrine/cache)
1615
- [Laravel cache](https://laravel.com/docs/5.2/cache)
1716
- [Flysystem](https://github.com/thephpleague/flysystem)
1817
- [PSR6](https://github.com/php-fig/cache)
18+
- [PSR16](https://github.com/php-fig/simple-cache)
1919
- [WordPress Object Cache](https://codex.wordpress.org/Class_Reference/WP_Object_Cache)
2020

2121
## Installation
@@ -47,49 +47,6 @@ $client = new Client(['handler' => $stack]);
4747

4848
# Examples
4949

50-
## Doctrine/Cache
51-
You can use a cache from `Doctrine/Cache`:
52-
```php
53-
[...]
54-
use Doctrine\Common\Cache\FilesystemCache;
55-
use Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy;
56-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
57-
58-
[...]
59-
$stack->push(
60-
new CacheMiddleware(
61-
new PrivateCacheStrategy(
62-
new DoctrineCacheStorage(
63-
new FilesystemCache('/tmp/')
64-
)
65-
)
66-
),
67-
'cache'
68-
);
69-
```
70-
71-
You can use `ChainCache` for using multiple `CacheProvider` instances. With that provider, you have to sort the different caches from the faster to the slower. Like that, you can have a very fast cache.
72-
```php
73-
[...]
74-
use Doctrine\Common\Cache\ChainCache;
75-
use Doctrine\Common\Cache\ArrayCache;
76-
use Doctrine\Common\Cache\FilesystemCache;
77-
use Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy;
78-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
79-
80-
[...]
81-
$stack->push(new CacheMiddleware(
82-
new PrivateCacheStrategy(
83-
new DoctrineCacheStorage(
84-
new ChainCache([
85-
new ArrayCache(),
86-
new FilesystemCache('/tmp/'),
87-
])
88-
)
89-
)
90-
), 'cache');
91-
```
92-
9350
## Laravel cache
9451
You can use a cache with Laravel, e.g. Redis, Memcache etc.:
9552
```php
@@ -155,19 +112,20 @@ $stack->push(
155112
It's possible to add a public shared cache to the stack:
156113
```php
157114
[...]
158-
use Doctrine\Common\Cache\FilesystemCache;
159-
use Doctrine\Common\Cache\PredisCache;
115+
use Cache\Adapter\PHPArray\ArrayCachePool;
160116
use Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy;
161117
use Kevinrob\GuzzleCache\Strategy\PublicCacheStrategy;
162-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
118+
use Kevinrob\GuzzleCache\Storage\Psr6CacheStorage;
119+
use League\Flysystem\Local\LocalFilesystemAdapter;
120+
use Kevinrob\GuzzleCache\Storage\FlysystemStorage;
163121

164122
[...]
165123
// Private caching
166124
$stack->push(
167125
new CacheMiddleware(
168126
new PrivateCacheStrategy(
169-
new DoctrineCacheStorage(
170-
new FilesystemCache('/tmp/')
127+
new FlysystemStorage(
128+
new LocalFilesystemAdapter('/tmp/')
171129
)
172130
)
173131
),
@@ -178,10 +136,8 @@ $stack->push(
178136
$stack->push(
179137
new CacheMiddleware(
180138
new PublicCacheStrategy(
181-
new DoctrineCacheStorage(
182-
new PredisCache(
183-
new Predis\Client('tcp://10.0.0.1:6379')
184-
)
139+
new Psr6CacheStorage(
140+
new ArrayCachePool()
185141
)
186142
)
187143
),
@@ -197,16 +153,16 @@ disregarding any possibly present caching headers:
197153
[...]
198154
use Kevinrob\GuzzleCache\KeyValueHttpHeader;
199155
use Kevinrob\GuzzleCache\Strategy\GreedyCacheStrategy;
200-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
201-
use Doctrine\Common\Cache\FilesystemCache;
156+
use Kevinrob\GuzzleCache\Storage\FlysystemStorage;
157+
use League\Flysystem\Local\LocalFilesystemAdapter;
202158

203159
[...]
204160
// Greedy caching
205161
$stack->push(
206162
new CacheMiddleware(
207163
new GreedyCacheStrategy(
208-
new DoctrineCacheStorage(
209-
new FilesystemCache('/tmp/')
164+
new FlysystemStorage(
165+
new LocalFilesystemAdapter('/tmp/')
210166
),
211167
1800, // the TTL in seconds
212168
new KeyValueHttpHeader(['Authorization']) // Optional - specify the headers that can change the cache key

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "kevinrob/guzzle-cache-middleware",
33
"type": "library",
44
"description": "A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)",
5-
"keywords": ["guzzle", "guzzle6", "cache", "http", "http 1.1", "psr6", "psr7", "handler", "middleware", "cache-control", "rfc7234", "performance", "php", "promise", "expiration", "validation", "Etag", "flysystem", "doctrine"],
5+
"keywords": ["guzzle", "guzzle6", "cache", "http", "http 1.1", "psr6", "psr7", "handler", "middleware", "cache-control", "rfc7234", "performance", "php", "promise", "expiration", "validation", "Etag", "flysystem"],
66
"homepage": "https://github.com/Kevinrob/guzzle-cache-middleware",
77
"license": "MIT",
88
"authors": [
@@ -20,7 +20,6 @@
2020
},
2121
"require-dev": {
2222
"phpunit/phpunit": "^9.6.21",
23-
"doctrine/cache": "^1.10",
2423
"league/flysystem": "^3.16",
2524
"psr/cache": "^1.0",
2625
"cache/array-adapter": "^0.4 || ^0.5 || ^1.0",
@@ -41,7 +40,6 @@
4140
},
4241
"suggest": {
4342
"guzzlehttp/guzzle": "For using this library. It was created for Guzzle6 (but you can use it with any PSR-7 HTTP client).",
44-
"doctrine/cache": "This library has a lot of ready-to-use cache storage (to be used with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage). Use only versions >=1.4.0 < 2.0.0",
4543
"league/flysystem": "To be used with Kevinrob\\GuzzleCache\\Storage\\FlysystemStorage",
4644
"psr/cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr6CacheStorage",
4745
"psr/simple-cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr16CacheStorage",

src/Storage/CompressedDoctrineCacheStorage.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/Storage/DoctrineCacheStorage.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

tests/PrivateCacheTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
use Cache\Adapter\PHPArray\ArrayCachePool;
66
use Cache\Bridge\SimpleCache\SimpleCacheBridge;
7-
use Doctrine\Common\Cache\ArrayCache;
8-
use Doctrine\Common\Cache\ChainCache;
9-
use Doctrine\Common\Cache\FilesystemCache;
10-
use Doctrine\Common\Cache\PhpFileCache;
117
use GuzzleHttp\Psr7\Request;
128
use GuzzleHttp\Psr7\Response;
139
use Kevinrob\GuzzleCache\Storage\CacheStorageInterface;
14-
use Kevinrob\GuzzleCache\Storage\CompressedDoctrineCacheStorage;
15-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
1610
use Kevinrob\GuzzleCache\Storage\FlysystemStorage;
1711
use Kevinrob\GuzzleCache\Storage\Psr6CacheStorage;
1812
use Kevinrob\GuzzleCache\Storage\Psr16CacheStorage;
@@ -85,14 +79,9 @@ public function cacheProvider()
8579
{
8680
$TMP_DIR = __DIR__.'/tmp/';
8781
return [
88-
'doctrine.arraycache' => [ new DoctrineCacheStorage(new ArrayCache()) ],
89-
'doctrine.chaincache' => [ new DoctrineCacheStorage(new ChainCache([new ArrayCache()])) ],
90-
'doctrine.filesystem' => [ new DoctrineCacheStorage(new FilesystemCache($TMP_DIR)), $TMP_DIR ],
91-
'doctrine.phpfile' => [ new DoctrineCacheStorage(new PhpFileCache($TMP_DIR)), $TMP_DIR ],
9282
'flysystem' => [ new FlysystemStorage(new LocalFilesystemAdapter($TMP_DIR)), $TMP_DIR ],
9383
'psr6' => [ new Psr6CacheStorage(new ArrayCachePool()) ],
9484
'psr16' => [ new Psr16CacheStorage(new SimpleCacheBridge(new ArrayCachePool())) ],
95-
'compressedDoctrineStorage' => [ new CompressedDoctrineCacheStorage(new ArrayCache()) ],
9685
'volatileruntimeStorage' => [ new VolatileRuntimeStorage() ]
9786
];
9887
}

tests/PublicCacheTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,12 @@
44

55
use Cache\Adapter\PHPArray\ArrayCachePool;
66
use Cache\Bridge\SimpleCache\SimpleCacheBridge;
7-
use Doctrine\Common\Cache\ArrayCache;
8-
use Doctrine\Common\Cache\CacheProvider;
9-
use Doctrine\Common\Cache\ChainCache;
10-
use Doctrine\Common\Cache\FilesystemCache;
11-
use Doctrine\Common\Cache\PhpFileCache;
127
use GuzzleHttp\Client;
138
use GuzzleHttp\HandlerStack;
149
use GuzzleHttp\Promise\FulfilledPromise;
1510
use GuzzleHttp\Psr7\Request;
1611
use GuzzleHttp\Psr7\Response;
1712
use Kevinrob\GuzzleCache\CacheMiddleware;
18-
use Kevinrob\GuzzleCache\Storage\CompressedDoctrineCacheStorage;
19-
use Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage;
2013
use Kevinrob\GuzzleCache\Storage\FlysystemStorage;
2114
use Kevinrob\GuzzleCache\Storage\Psr6CacheStorage;
2215
use Kevinrob\GuzzleCache\Storage\Psr16CacheStorage;
@@ -96,14 +89,9 @@ public function testCacheProvider()
9689
$TMP_DIR = __DIR__.'/tmp/';
9790

9891
$cacheProviders = [
99-
new DoctrineCacheStorage(new ArrayCache()),
100-
new DoctrineCacheStorage(new ChainCache([new ArrayCache()])),
101-
new DoctrineCacheStorage(new FilesystemCache($TMP_DIR)),
102-
new DoctrineCacheStorage(new PhpFileCache($TMP_DIR)),
10392
new FlysystemStorage(new LocalFilesystemAdapter($TMP_DIR)),
10493
new Psr6CacheStorage(new ArrayCachePool()),
10594
new Psr16CacheStorage(new SimpleCacheBridge(new ArrayCachePool())),
106-
new CompressedDoctrineCacheStorage(new ArrayCache()),
10795
new VolatileRuntimeStorage(),
10896
];
10997

@@ -121,7 +109,6 @@ public function testCacheProvider()
121109
'Test new content'
122110
);
123111

124-
/** @var CacheProvider $cacheProvider */
125112
foreach ($cacheProviders as $cacheProvider) {
126113
$this->rrmdir($TMP_DIR);
127114

0 commit comments

Comments
 (0)