20
20
use Symfony \Component \Cache \Marshaller \DeflateMarshaller ;
21
21
use Symfony \Component \Cache \Marshaller \MarshallerInterface ;
22
22
use Symfony \Component \Cache \Marshaller \TagAwareMarshaller ;
23
+ use Symfony \Component \Cache \Traits \RedisClusterProxy ;
24
+ use Symfony \Component \Cache \Traits \RedisProxy ;
23
25
use Symfony \Component \Cache \Traits \RedisTrait ;
24
26
25
27
/**
@@ -57,18 +59,18 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
57
59
private $ redisEvictionPolicy ;
58
60
59
61
/**
60
- * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface $redisClient The redis client
61
- * @param string $namespace The default namespace
62
- * @param int $defaultLifetime The default lifetime
62
+ * @param \Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|RedisProxy|RedisClusterProxy $redis The redis client
63
+ * @param string $namespace The default namespace
64
+ * @param int $defaultLifetime The default lifetime
63
65
*/
64
- public function __construct ($ redisClient , string $ namespace = '' , int $ defaultLifetime = 0 , MarshallerInterface $ marshaller = null )
66
+ public function __construct ($ redis , string $ namespace = '' , int $ defaultLifetime = 0 , MarshallerInterface $ marshaller = null )
65
67
{
66
- if ($ redisClient instanceof \Predis \ClientInterface && $ redisClient ->getConnection () instanceof ClusterInterface && !$ redisClient ->getConnection () instanceof PredisCluster) {
67
- throw new InvalidArgumentException (sprintf ('Unsupported Predis cluster connection: only "%s" is, "%s" given. ' , PredisCluster::class, \get_class ($ redisClient ->getConnection ())));
68
+ if ($ redis instanceof \Predis \ClientInterface && $ redis ->getConnection () instanceof ClusterInterface && !$ redis ->getConnection () instanceof PredisCluster) {
69
+ throw new InvalidArgumentException (sprintf ('Unsupported Predis cluster connection: only "%s" is, "%s" given. ' , PredisCluster::class, \get_class ($ redis ->getConnection ())));
68
70
}
69
71
70
- if (\defined ('Redis::OPT_COMPRESSION ' ) && ($ redisClient instanceof \Redis || $ redisClient instanceof \RedisArray || $ redisClient instanceof \RedisCluster)) {
71
- $ compression = $ redisClient ->getOption (\Redis::OPT_COMPRESSION );
72
+ if (\defined ('Redis::OPT_COMPRESSION ' ) && ($ redis instanceof \Redis || $ redis instanceof \RedisArray || $ redis instanceof \RedisCluster)) {
73
+ $ compression = $ redis ->getOption (\Redis::OPT_COMPRESSION );
72
74
73
75
foreach (\is_array ($ compression ) ? $ compression : [$ compression ] as $ c ) {
74
76
if (\Redis::COMPRESSION_NONE !== $ c ) {
@@ -77,7 +79,7 @@ public function __construct($redisClient, string $namespace = '', int $defaultLi
77
79
}
78
80
}
79
81
80
- $ this ->init ($ redisClient , $ namespace , $ defaultLifetime , new TagAwareMarshaller ($ marshaller ));
82
+ $ this ->init ($ redis , $ namespace , $ defaultLifetime , new TagAwareMarshaller ($ marshaller ));
81
83
}
82
84
83
85
/**
0 commit comments