@@ -22,6 +22,9 @@ class Evictor
2222 const DEFAULT_SLEEP_TIMEOUT = 20000 ;
2323 const CONFIG_PATH_ENABLED = 'cache_evict/enabled ' ;
2424 const CONFIG_PATH_LIMIT = 'cache_evict/limit ' ;
25+ const BACKEND_OPTION_KEY_SERVER = 'server ' ;
26+ const BACKEND_OPTION_KEY_PORT = 'port ' ;
27+ const BACKEND_OPTION_KEY_DATABASE = 'database ' ;
2528
2629 /**
2730 * @var DeploymentConfig
@@ -60,11 +63,8 @@ public function evict(): int
6063 $ name
6164 ));
6265
63- if (!isset (
64- $ cacheConfig ['backend_options ' ]['server ' ],
65- $ cacheConfig ['backend_options ' ]['port ' ],
66- $ cacheConfig ['backend_options ' ]['database ' ]
67- )) {
66+ $ backendOptions = $ this ->getConfigBackendOptions ((array )$ cacheConfig );
67+ if (!$ this ->validateBackendOptions ($ backendOptions )) {
6868 $ this ->logger ->debug (sprintf (
6969 'Cache config for database "%s" config is not valid ' ,
7070 $ name
@@ -74,9 +74,9 @@ public function evict(): int
7474 }
7575
7676 $ dbKeys = $ this ->run (
77- (string )$ cacheConfig [ ' backend_options ' ][ ' server ' ],
78- (int )$ cacheConfig [ ' backend_options ' ][ ' port ' ],
79- (int )$ cacheConfig [ ' backend_options ' ][ ' database ' ]
77+ (string )$ backendOptions [ self :: BACKEND_OPTION_KEY_SERVER ],
78+ (int )$ backendOptions [ self :: BACKEND_OPTION_KEY_PORT ],
79+ (int )$ backendOptions [ self :: BACKEND_OPTION_KEY_DATABASE ]
8080 );
8181 $ evictedKeys += $ dbKeys ;
8282
@@ -86,6 +86,41 @@ public function evict(): int
8686 return $ evictedKeys ;
8787 }
8888
89+ /**
90+ * Get Cache Config Value
91+ *
92+ * @param array $cacheConfig
93+ * @return array
94+ */
95+ private function getConfigBackendOptions (array $ cacheConfig ): array
96+ {
97+ $ backendOptions = [];
98+ if (isset ($ cacheConfig ['backend_options ' ])) {
99+ $ backendOptions = $ cacheConfig ['backend_options ' ];
100+ }
101+ if (isset ($ cacheConfig ['backend_options ' ]['remote_backend_options ' ])) {
102+ $ backendOptions = $ cacheConfig ['backend_options ' ]['remote_backend_options ' ];
103+ }
104+ return (array )$ backendOptions ;
105+ }
106+
107+ /**
108+ * Validate Cache Configuration
109+ *
110+ * @param array $backendOptions
111+ * @return bool
112+ */
113+ private function validateBackendOptions (array $ backendOptions ): bool
114+ {
115+ if (isset ($ backendOptions [self ::BACKEND_OPTION_KEY_SERVER ])
116+ && isset ($ backendOptions [self ::BACKEND_OPTION_KEY_PORT ])
117+ && isset ($ backendOptions [self ::BACKEND_OPTION_KEY_DATABASE ])
118+ ) {
119+ return true ;
120+ }
121+ return false ;
122+ }
123+
89124 /**
90125 * @param string $host
91126 * @param int $port
0 commit comments