Flush cache + getFlushCacheStatus(); ?> + getFlushTimeAgo(); ?> + | ++ + | +
---|
From 5a9a87d42ab65c054726ada1681eaeb34b44feb6 Mon Sep 17 00:00:00 2001 From: Pedro de Carvalho
Date: Fri, 24 Jan 2020 22:25:05 +0000
Subject: [PATCH] Improve flush cache
---
README.md | 4 ++-
opcache.php | 99 ++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 86 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 87c21b6..e2a39c8 100644
--- a/README.md
+++ b/README.md
@@ -10,13 +10,15 @@ See the data-sample.php file for a dump of the data.
## Change log
+### v0.2.1
+- Improve flush cache
+
### v0.2.0
- Fixed warnings when opcache was off
- Improve clear cache feedback
- Changed label from Scripts to Files
-
### TODO
- The ability to sort the list of cached scripts by the various columns
diff --git a/opcache.php b/opcache.php
index 1e1afca..9334158 100644
--- a/opcache.php
+++ b/opcache.php
@@ -6,7 +6,7 @@
* https://github.com/wp-cloud/opcache-status
*
* @package OpCacheStatus
- * @version 0.2.0
+ * @version 0.2.1
* @author WP-Cloud %1$s Last reset was ';
+ $reset_ago_end = '
* @copyright Copyright (c) 2016, WP-Cloud
* @copyright Copyright (c) -2016, Rasmus Lerdorf
@@ -32,6 +32,7 @@ public function __construct()
{
$this->_configuration = opcache_get_configuration();
$this->_status = opcache_get_status() ?: [];
+ $this->handleFlush();
}
public function getPageTitle()
@@ -39,6 +40,8 @@ public function getPageTitle()
return 'PHP ' . phpversion() . " with OpCache {$this->_configuration['version']['version']}";
}
+
+
public function getStatusDataRows()
{
$rows = array();
@@ -314,30 +317,68 @@ private function _arrayPset(&$array, $key, $value)
return $array;
}
- public function clearCache() {
+ private function flushCache() {
+ if ( ! function_exists('opcache_reset') ) {
+ return;
+ }
return (int) opcache_reset();
}
- public function clearCacheStatus() {
+ /**
+ * Check if flush was properly done and present it
+ */
+ public function getFlushCacheStatus() {
+ $status_msg = '(failed)';
+ if ( ! isset( $_GET['flush_status'] ) ) {
+ return '';
+ }
+ if ( $_GET['flush_status'] == 1) {
+ $status_msg = '(success)';
+ }
+ printf( '
getPageTitle(); ?>
-
+
+
+
+ Flush cache
+ getFlushCacheStatus(); ?>
+ getFlushTimeAgo(); ?>
+
+
+
+
+