@@ -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,7 +63,8 @@ public function evict(): int
6063 $ name
6164 ));
6265
63- if (!$ this ->isCacheConfigValid ($ cacheConfig )) {
66+ $ backendOptions = $ this ->getConfigBackendOptions ((array )$ cacheConfig );
67+ if (!$ this ->validateBackendOptions ($ backendOptions )) {
6468 $ this ->logger ->debug (sprintf (
6569 'Cache config for database "%s" config is not valid ' ,
6670 $ name
@@ -70,9 +74,9 @@ public function evict(): int
7074 }
7175
7276 $ dbKeys = $ this ->run (
73- (string )$ this -> getCacheConfigValue ( $ name , $ cacheConfig , ' server ' ) ,
74- (int )$ this -> getCacheConfigValue ( $ name , $ cacheConfig , ' port ' ) ,
75- (int )$ this -> getCacheConfigValue ( $ name , $ cacheConfig , ' 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 ]
7680 );
7781 $ evictedKeys += $ dbKeys ;
7882
@@ -86,31 +90,31 @@ public function evict(): int
8690 * Get Cache Config Value
8791 *
8892 * @param array $cacheConfig
89- * @param string $configKey
90- * @return string
93+ * @return array
9194 */
92- private function getCacheConfigValue ( $ cacheConfig , $ configKey ): string
95+ private function getConfigBackendOptions ( array $ cacheConfig ): array
9396 {
94- if (isset ($ cacheConfig ['backend_options ' ][$ configKey ])) {
95- return $ cacheConfig ['backend_options ' ][$ configKey ];
97+ $ backendOptions = [];
98+ if (isset ($ cacheConfig ['backend_options ' ])) {
99+ $ backendOptions = $ cacheConfig ['backend_options ' ];
96100 }
97- if (isset ($ cacheConfig ['backend_options ' ]['remote_backend_options ' ][ $ configKey ] )) {
98- return $ cacheConfig ['backend_options ' ]['remote_backend_options ' ][ $ configKey ];
101+ if (isset ($ cacheConfig ['backend_options ' ]['remote_backend_options ' ])) {
102+ $ backendOptions = $ cacheConfig ['backend_options ' ]['remote_backend_options ' ];
99103 }
100- return '' ;
104+ return ( array ) $ backendOptions ;
101105 }
102106
103107 /**
104108 * Validate Cache Configuration
105109 *
106- * @param $cacheConfig
110+ * @param array $backendOptions
107111 * @return bool
108112 */
109- private function isCacheConfigValid ( $ cacheConfig ): bool
113+ private function validateBackendOptions ( array $ backendOptions ): bool
110114 {
111- if ($ this -> getCacheConfigValue ( $ cacheConfig , ' server ' )
112- && $ this -> getCacheConfigValue ( $ cacheConfig , ' port ' )
113- && $ this -> getCacheConfigValue ( $ cacheConfig , ' database ' )
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 ] )
114118 ) {
115119 return true ;
116120 }
0 commit comments