Permalink
Browse files

Merge pull request #4306 from jdarwood007/cache_api

Add getVersion to Cache API
  • Loading branch information...
Oldiesmann committed Oct 13, 2017
2 parents be0371a + 9a5cfc3 commit 11eb4306d393af0427b10c75c7eed5fefb606343
View
@@ -74,6 +74,14 @@ public function cleanCache($type = '')
$this->invalidateCache();
return true;
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return phpversion('apc');
}
}
?>
@@ -64,6 +64,14 @@ public function cleanCache($type = '')
$this->invalidateCache();
return apcu_clear_cache();
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return phpversion('apcu');
}
}
?>
@@ -141,6 +141,14 @@ public function cacheSettings(array &$config_vars)
$("#cache_memcached").prop("disabled", cache_type != "memcache");
});';
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return $this->memcache->getVersion();
}
}
?>
@@ -144,6 +144,14 @@ public function cacheSettings(array &$config_vars)
$("#cache_memcached").prop("disabled", cache_type != "memcached");
});';
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return $this->memcached->getVersion();
}
}
?>
@@ -20,7 +20,6 @@
*/
class postgres_cache extends cache_api
{
/**
* @var false|resource of the pg_prepare from get_data.
*/
@@ -34,7 +33,6 @@ class postgres_cache extends cache_api
public function __construct()
{
parent::__construct();
}
/**
@@ -61,7 +59,6 @@ public function connect()
public function isSupported($test = false)
{
global $smcFunc, $db_connection;
if ($smcFunc['db_title'] !== 'PostgreSQL')
return false;
@@ -108,7 +105,7 @@ public function putData($key, $value, $ttl = null)
$value = '';
$ttl = time() + $ttl;
if (empty($this->pg_put_data_prep))
$this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data',
'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3)
@@ -137,6 +134,16 @@ public function cleanCache($type = '')
return true;
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
global $smcFunc;
return $smcFunc['db_server_info']();
}
}
?>
View
@@ -203,6 +203,16 @@ public function getCachedir()
{
return $this->cachedir;
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
global $forum_version;
return isset($forum_version) ? $forum_version : '2.1';
}
}
?>
@@ -37,12 +37,10 @@ class sqlite_cache extends cache_api
public function __construct()
{
parent::__construct();
// Set our default cachedir.
$this->setCachedir();
}
/**
@@ -71,9 +69,7 @@ public function isSupported($test = false)
$supported = class_exists("SQLite3") && is_writable($this->cachedir);
if ($test)
{
return $supported;
}
return parent::isSupported() && $supported;
}
@@ -89,9 +85,7 @@ public function getData($key, $ttl = null)
$value = null;
while ($res = $result->fetchArray(SQLITE3_ASSOC))
{
$value = $res['value'];
}
return !empty($value) ? $value : null;
}
@@ -119,7 +113,6 @@ public function cleanCache($type = '')
$result = $this->cacheDB->exec($query);
return $result;
}
/**
@@ -133,9 +126,7 @@ public function cacheSettings(array &$config_vars)
$config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir');
if (!isset($context['settings_post_javascript']))
{
$context['settings_post_javascript'] = '';
}
$context['settings_post_javascript'] .= '
$("#cache_accelerator").change(function (e) {
@@ -159,15 +150,19 @@ public function setCachedir($dir = null)
// If its invalid, use SMF's.
if (is_null($dir) || !is_writable($dir))
{
$this->cachedir = $cachedir_sqlite;
}
else
{
$this->cachedir = $dir;
}
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
$temp = $this->cacheDB->version();
return $temp['versionString'];
}
}
?>
@@ -120,6 +120,14 @@ public function cacheSettings(array &$config_vars)
$("#xcache_adminpass").prop("disabled", cache_type != "xcache");
});';
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return XCACHE_VERSION;
}
}
?>
@@ -68,6 +68,14 @@ public function cleanCache($type = '')
return zend_shm_cache_clear('SMF');
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return zend_version();
}
}
?>
View
@@ -138,6 +138,14 @@ public function getCompatibleVersion();
* @return string the value of $key.
*/
public function getMiniumnVersion();
/**
* Gets the Version of the Caching API.
*
* @access public
* @return string the value of $key.
*/
public function getVersion();
}
/**
@@ -311,6 +319,14 @@ public function getMiniumnVersion()
{
return $this->min_smf_version;
}
/**
* {@inheritDoc}
*/
public function getVersion()
{
return $this->min_smf_version;
}
}
?>
View
@@ -23,7 +23,7 @@
*/
function getServerVersions($checkFor)
{
global $txt, $db_connection, $_PHPA, $smcFunc, $memcached, $modSettings;
global $txt, $db_connection, $_PHPA, $smcFunc, $cache_accelerator, $cache_memcached, $cacheAPI, $modSettings;
loadLanguage('Admin');
@@ -74,16 +74,17 @@ function getServerVersions($checkFor)
}
// If we're using memcache we need the server info.
if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '')
get_memcached_server();
$memcache_version = '???';
if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI))
$memcache_version = $cacheAPI->getVersion();
// Check to see if we have any accelerators installed...
if (in_array('phpa', $checkFor) && isset($_PHPA))
$versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
if (in_array('apc', $checkFor) && extension_loaded('apc'))
$versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
if (in_array('memcache', $checkFor) && function_exists('memcache_set'))
$versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached));
$versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version);
if (in_array('xcache', $checkFor) && function_exists('xcache_set'))
$versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
@@ -439,10 +440,10 @@ function updateSettingsFile($config_vars)
*/
function updateDbLastError($time)
{
global $boarddir;
global $boarddir, $cachedir;
// Write out the db_last_error file with the error timestamp
file_put_contents($boarddir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = ' . $time . ';' . "\n" . '?' . '>', LOCK_EX);
file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = ' . $time . ';' . "\n" . '?' . '>', LOCK_EX);
@touch($boarddir . '/' . 'Settings.php');
}
/**

0 comments on commit 11eb430

Please sign in to comment.