@@ -60,11 +60,7 @@ public function evict(): int
60
60
$ name
61
61
));
62
62
63
- if (!isset (
64
- $ cacheConfig ['backend_options ' ]['server ' ],
65
- $ cacheConfig ['backend_options ' ]['port ' ],
66
- $ cacheConfig ['backend_options ' ]['database ' ]
67
- )) {
63
+ if (!$ this ->isCacheConfigValid ($ cacheConfig )) {
68
64
$ this ->logger ->debug (sprintf (
69
65
'Cache config for database "%s" config is not valid ' ,
70
66
$ name
@@ -74,9 +70,9 @@ public function evict(): int
74
70
}
75
71
76
72
$ dbKeys = $ this ->run (
77
- (string )$ cacheConfig[ ' backend_options ' ][ ' server '] ,
78
- (int )$ cacheConfig[ ' backend_options ' ][ ' port '] ,
79
- (int )$ cacheConfig[ ' backend_options ' ][ ' database ']
73
+ (string )$ this -> getCacheConfigValue ( $ name , $ cacheConfig, ' server ') ,
74
+ (int )$ this -> getCacheConfigValue ( $ name , $ cacheConfig, ' port ') ,
75
+ (int )$ this -> getCacheConfigValue ( $ name , $ cacheConfig, ' database ')
80
76
);
81
77
$ evictedKeys += $ dbKeys ;
82
78
@@ -86,6 +82,41 @@ public function evict(): int
86
82
return $ evictedKeys ;
87
83
}
88
84
85
+ /**
86
+ * Get Cache Config Value
87
+ *
88
+ * @param array $cacheConfig
89
+ * @param string $configKey
90
+ * @return string
91
+ */
92
+ private function getCacheConfigValue ($ cacheConfig , $ configKey )
93
+ {
94
+ if (isset ($ cacheConfig ['backend_options ' ][$ configKey ])) {
95
+ return $ cacheConfig ['backend_options ' ][$ configKey ];
96
+ }
97
+ if (isset ($ cacheConfig ['backend_options ' ]['remote_backend_options ' ][$ configKey ])) {
98
+ return $ cacheConfig ['backend_options ' ]['remote_backend_options ' ][$ configKey ];
99
+ }
100
+ return '' ;
101
+ }
102
+
103
+ /**
104
+ * Validate Cache Configuration
105
+ *
106
+ * @param $cacheConfig
107
+ * @return bool
108
+ */
109
+ private function isCacheConfigValid ($ cacheConfig )
110
+ {
111
+ if ($ this ->getCacheConfigValue ($ cacheConfig , 'server ' )
112
+ && $ this ->getCacheConfigValue ($ cacheConfig , 'port ' )
113
+ && $ this ->getCacheConfigValue ($ cacheConfig , 'database ' )
114
+ ) {
115
+ return true ;
116
+ }
117
+ return false ;
118
+ }
119
+
89
120
/**
90
121
* @param string $host
91
122
* @param int $port
0 commit comments