Skip to content

Commit a4db63f

Browse files
committed
Update the getStats() function for zend memory cache
1 parent 91dab16 commit a4db63f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/phpFastCache/Drivers/Zendshm/Driver.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,20 @@ protected function driverConnect()
130130
*/
131131
public function getStats()
132132
{
133-
$stats = (array) zend_shm_cache_info();
134-
return (new driverStatistic())
135-
->setData(implode(', ', array_keys($this->namespaces)))
136-
->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.",$stats[ 'items_total' ]))
137-
->setRawData($stats)
138-
->setSize($stats[ 'memory_total' ]);
133+
if(function_exists('zend_shm_cache_info')) {
134+
$stats = (array)zend_shm_cache_info();
135+
return (new driverStatistic())
136+
->setData(implode(', ', array_keys($this->namespaces)))
137+
->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
138+
->setRawData($stats)
139+
->setSize($stats['memory_total']);
140+
} else {
141+
/** zend_shm_cache_info supported V8 or higher */
142+
return (new driverStatistic())
143+
->setData(implode(', ', array_keys($this->namespaces)))
144+
->setInfo("The Zend memory statistics is only supported by ZendServer V8 or higher")
145+
->setRawData(null)
146+
->setSize(0);
147+
}
139148
}
140149
}

0 commit comments

Comments
 (0)