File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
src/Symfony/Component/Cache Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public function __construct(CacheItemPoolInterface $pool)
44
44
$ createCacheItem = \Closure::bind (
45
45
static function ($ key , $ value , $ allowInt = false ) use (&$ cacheItemPrototype ) {
46
46
$ item = clone $ cacheItemPrototype ;
47
+ $ item ->poolHash = $ item ->innerItem = null ;
47
48
$ item ->key = $ allowInt && \is_int ($ key ) ? (string ) $ key : CacheItem::validateKey ($ key );
48
49
$ item ->value = $ value ;
49
50
$ item ->isHit = false ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Symfony \Component \Cache \Tests ;
4
+
5
+ use Cache \IntegrationTests \SimpleCacheTest ;
6
+ use Psr \SimpleCache \CacheInterface ;
7
+ use Symfony \Component \Cache \Adapter \ArrayAdapter ;
8
+ use Symfony \Component \Cache \Adapter \ProxyAdapter ;
9
+ use Symfony \Component \Cache \Psr16Cache ;
10
+
11
+ class Psr16CacheProxyTest extends SimpleCacheTest
12
+ {
13
+ public function createSimpleCache (int $ defaultLifetime = 0 ): CacheInterface
14
+ {
15
+ return new Psr16Cache (new ProxyAdapter (new ArrayAdapter ($ defaultLifetime ), 'my-namespace. ' ));
16
+ }
17
+
18
+ public function testProxy ()
19
+ {
20
+ $ pool = new ArrayAdapter ();
21
+ $ cache = new Psr16Cache (new ProxyAdapter ($ pool , 'my-namespace. ' ));
22
+
23
+ $ this ->assertNull ($ cache ->get ('some-key ' ));
24
+ $ this ->assertTrue ($ cache ->set ('some-other-key ' , 'value ' ));
25
+
26
+ $ item = $ pool ->getItem ('my-namespace.some-other-key ' , 'value ' );
27
+ $ this ->assertTrue ($ item ->isHit ());
28
+ $ this ->assertSame ('value ' , $ item ->get ());
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments