2424 private const string DEFAULT_PREFIX = 'react:cache: ' ;
2525 private const int DEFAULT_TTL = 0 ;
2626
27- /** @phpstan-ignore-next-line */
2827 public function __construct (private Client $ client , private string $ prefix = self ::DEFAULT_PREFIX , private int $ ttl = self ::DEFAULT_TTL )
2928 {
3029 }
3130
32- /**
33- * @inheritDoc
34- * @phpstan-ignore-next-line
35- */
31+ /** @inheritDoc */
3632 public function get ($ key , $ default = null ): PromiseInterface
3733 {
3834 return $ this ->has ($ key )->then (function (mixed $ result ) use ($ key ): PromiseInterface {
3935 if ($ result === false ) {
4036 return resolve (null );
4137 }
4238
43- /** @phpstan-ignore-next-line */
4439 return $ this ->client ->get ($ this ->prefix . $ key );
4540 });
4641 }
4742
48- /**
49- * @inheritDoc
50- * @phpstan-ignore-next-line
51- */
43+ /** @inheritDoc */
5244 public function set ($ key , $ value , $ ttl = null ): PromiseInterface
5345 {
5446 if ($ this ->ttl === 0 && $ ttl === null ) {
55- /** @phpstan-ignore-next-line */
5647 return $ this ->client ->set ($ this ->prefix . $ key , (string ) $ value )->then (
5748 static fn (): PromiseInterface => resolve (true ),
5849 static fn (): PromiseInterface => resolve (false ),
5950 );
6051 }
6152
62- /** @phpstan-ignore-next-line */
6353 return $ this ->client ->psetex (
6454 $ this ->prefix . $ key ,
6555 (string ) ((float ) ($ this ->ttl > 0 ? $ this ->ttl : $ ttl ) * 1000 ),
66- (string ) $ value , /** @phpstan-ignore-line */
56+ (string ) $ value ,
6757 )->then (
6858 static fn (): PromiseInterface => resolve (true ),
6959 static fn (): PromiseInterface => resolve (false ),
7060 );
7161 }
7262
73- /**
74- * @inheritDoc
75- * @phpstan-ignore-next-line
76- */
63+ /** @inheritDoc */
7764 public function delete ($ key ): PromiseInterface
7865 {
79- /** @phpstan-ignore-next-line */
8066 return $ this ->client ->del ($ this ->prefix . $ key )->then (
8167 static fn (): PromiseInterface => resolve (true ),
8268 static fn (): PromiseInterface => resolve (false ),
8369 );
8470 }
8571
86- /**
87- * @inheritDoc
88- * @phpstan-ignore-next-line
89- */
72+ /** @inheritDoc */
9073 public function getMultiple (array $ keys , $ default = null )
9174 {
9275 $ promises = [];
@@ -97,10 +80,7 @@ public function getMultiple(array $keys, $default = null)
9780 return all ($ promises );
9881 }
9982
100- /**
101- * @inheritDoc
102- * @phpstan-ignore-next-line
103- */
83+ /** @inheritDoc */
10484 public function setMultiple (array $ values , $ ttl = null )
10585 {
10686 $ promises = [];
@@ -112,37 +92,27 @@ public function setMultiple(array $values, $ttl = null)
11292 return all ($ promises )->then (static fn (array $ bools ): bool => array_all ($ bools , static fn (bool $ bool ): bool => $ bool ));
11393 }
11494
115- /**
116- * @inheritDoc
117- * @phpstan-ignore-next-line
118- */
95+ /** @inheritDoc */
11996 public function deleteMultiple (array $ keys )
12097 {
12198 foreach ($ keys as $ index => $ key ) {
12299 $ keys [$ index ] = $ this ->prefix . $ key ;
123100 }
124101
125- return $ this ->client ->del (...$ keys )->then ( /** @phpstan-ignore-line */
102+ return $ this ->client ->del (...$ keys )->then (
126103 static fn (): PromiseInterface => resolve (true ),
127104 static fn (): PromiseInterface => resolve (false ),
128105 );
129106 }
130107
131- /**
132- * @inheritDoc
133- * @phpstan-ignore-next-line
134- */
108+ /** @inheritDoc */
135109 public function clear ()
136110 {
137- return $ this ->client ->keys ($ this ->prefix . '* ' )->then ( /** @phpstan-ignore-line */
111+ return $ this ->client ->keys ($ this ->prefix . '* ' )->then (
138112 function (array $ keys ): PromiseInterface {
139- /**
140- * @var array<string> $matchedKeys
141- * @phpstan-ignore-next-line
142- */
113+ /** @var array<string> $matchedKeys */
143114 $ matchedKeys = preg_replace ('|^ ' . preg_quote ($ this ->prefix ) . '| ' , '' , $ keys );
144115 if (preg_last_error () !== PREG_NO_ERROR ) {
145- /** @phpstan-ignore-next-line */
146116 throw new RuntimeException (preg_last_error_msg ());
147117 }
148118
@@ -151,13 +121,9 @@ function (array $keys): PromiseInterface {
151121 );
152122 }
153123
154- /**
155- * @inheritDoc
156- * @phpstan-ignore-next-line
157- */
124+ /** @inheritDoc */
158125 public function has ($ key )
159126 {
160- /** @phpstan-ignore-next-line */
161127 return $ this ->client ->exists ($ this ->prefix . $ key );
162128 }
163129}
0 commit comments