| @@ 183-197 (lines=15) @@ | ||
| 180 | /** |
|
| 181 | * @return DriverStatistic |
|
| 182 | */ |
|
| 183 | public function getStats() |
|
| 184 | { |
|
| 185 | $stats = (array)$this->instance->getstats(); |
|
| 186 | $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 187 | $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
| 188 | $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 189 | ||
| 190 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
| 191 | ||
| 192 | return (new DriverStatistic()) |
|
| 193 | ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 194 | ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 195 | ->setRawData($stats) |
|
| 196 | ->setSize($stats[ 'bytes' ]); |
|
| 197 | } |
|
| 198 | } |
|
| @@ 177-191 (lines=15) @@ | ||
| 174 | /** |
|
| 175 | * @return DriverStatistic |
|
| 176 | */ |
|
| 177 | public function getStats() |
|
| 178 | { |
|
| 179 | $stats = current($this->instance->getStats()); |
|
| 180 | $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 181 | $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : $this->instance->getVersion()); |
|
| 182 | $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 183 | ||
| 184 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
| 185 | ||
| 186 | return (new DriverStatistic()) |
|
| 187 | ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 188 | ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 189 | ->setRawData($stats) |
|
| 190 | ->setSize($stats[ 'bytes' ]); |
|
| 191 | } |
|
| 192 | } |
|
| @@ 192-204 (lines=13) @@ | ||
| 189 | /** |
|
| 190 | * @return DriverStatistic |
|
| 191 | */ |
|
| 192 | public function getStats() |
|
| 193 | { |
|
| 194 | $info = $this->instance->info(); |
|
| 195 | $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
| 196 | $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
| 197 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 198 | ||
| 199 | return (new DriverStatistic()) |
|
| 200 | ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 201 | ->setRawData($info) |
|
| 202 | ->setSize($size) |
|
| 203 | ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
| 204 | $version, $date->format(DATE_RFC2822))); |
|
| 205 | } |
|
| 206 | } |
|