本文整理汇总了PHP中mmcache_get函数的典型用法代码示例。如果您正苦于以下问题:PHP mmcache_get函数的具体用法?PHP mmcache_get怎么用?PHP mmcache_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mmcache_get函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* load template from cache
*
* @access public
* @param string cache key
* @param integer modification time of original template
* @return array|boolean either an array containing the templates or false cache could not be loaded
*/
function load($key, $modTime = -1)
{
if (!function_exists('mmcache_lock')) {
return false;
}
$something = mmcache_get($key);
if (is_null($something)) {
return false;
} else {
return unserialize($something);
}
}
示例2: get
/**
* (Plug-in replacement for memcache API) Get data from the persistant cache.
*
* @param mixed Key
* @param ?TIME Minimum timestamp that entries from the cache may hold (NULL: don't care)
* @return ?mixed The data (NULL: not found / NULL entry)
*/
function get($key, $min_cache_date = NULL)
{
if (function_exists('eaccelerator_get')) {
$data = eaccelerator_get($key);
} elseif (function_exists('mmcache_get')) {
$data = mmcache_get($key);
}
if (is_null($data)) {
return NULL;
}
if (!is_null($min_cache_date) && $data[0] < $min_cache_date) {
return NULL;
}
return unserialize($data[1]);
}
示例3: cache_get_data
function cache_get_data($key, $ttl = 120)
{
global $boardurl, $sourcedir, $modSettings, $memcached;
global $cache_hits, $cache_count, $db_show_debug;
if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
return;
}
$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
$st = microtime();
}
$key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . $key;
// Okay, let's go for it memcached!
if (function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
// Not connected yet?
if (empty($memcached)) {
get_memcached_server();
}
if (!$memcached) {
return;
}
$value = memcache_get($memcached, $key);
} elseif (function_exists('eaccelerator_get')) {
$value = eaccelerator_get($key);
} elseif (function_exists('mmcache_get')) {
$value = mmcache_get($key);
} elseif (function_exists('apc_fetch')) {
$value = apc_fetch($key . 'smf');
} elseif (function_exists('output_cache_get')) {
$value = output_cache_get($key, $ttl);
}
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
$cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
}
if (empty($value)) {
return null;
} else {
return @unserialize($value);
}
}
示例4: smfapi_cacheGetData
/**
* Get data from the cache
*
* Get data from the cache that matches this key, if it exists
*
* @param string $key the cache data identifier
* @param int $ttl how long will the data be considered fresh (in seconds)
* @return mixed $value the cache data or null
* @since 0.1.0
*/
function smfapi_cacheGetData($key, $ttl = 120)
{
global $boardurl, $sourcedir, $modSettings, $memcached;
global $cache_hits, $cache_count, $db_show_debug, $cachedir;
if (empty($modSettings['cache_enable']) && !empty($modSettings)) {
return;
}
$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
$st = microtime();
}
$key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . strtr($key, ':', '-');
// again, eAccelerator.
if (function_exists('eaccelerator_get')) {
$value = eaccelerator_get($key);
} elseif (function_exists('mmcache_get')) {
$value = mmcache_get($key);
} elseif (function_exists('apc_fetch')) {
$value = apc_fetch($key . 'smf');
} elseif (function_exists('output_cache_get')) {
$value = output_cache_get($key, $ttl);
} elseif (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
$value = xcache_get($key);
} elseif (file_exists($cachedir . '/data_' . $key . '.php') && filesize($cachedir . '/data_' . $key . '.php') > 10) {
require $cachedir . '/data_' . $key . '.php';
if (!empty($expired) && isset($value)) {
@unlink($cachedir . '/data_' . $key . '.php');
unset($value);
}
}
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
$cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
}
if (empty($value)) {
return null;
} else {
return @unserialize($value);
}
}
示例5: get
/**
* returns value of variable in shared mem
*
* @param string $name name of variable
*
* @return mixed value of the variable
* @access public
*/
function get($name)
{
return mmcache_get($name);
}
示例6: get
function get($key)
{
$val = mmcache_get($key);
if (is_string($val)) {
$val = unserialize($val);
}
return $val;
}
示例7: cache_get_data
/**
* Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
* - It may often "miss", so shouldn't be depended on.
* - It supports the same as cache_put_data().
*
* @param string $key
* @param int $ttl = 120
*/
function cache_get_data($key, $ttl = 120)
{
global $cache_memcached, $memcached, $cache_hits, $cache_count, $db_show_debug;
global $cache_accelerator, $cache_enable, $expired;
if (empty($cache_enable)) {
return;
}
$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
$st = microtime(true);
}
$key = cache_get_key($key);
switch ($cache_accelerator) {
case 'memcached':
// Okay, let's go for it memcached!
if ((function_exists('memcache_get') || function_exists('memcached_get')) && !empty($cache_memcached)) {
// Not connected yet?
if (empty($memcached)) {
get_memcached_server();
}
if (!$memcached) {
return null;
}
$value = function_exists('memcache_get') ? memcache_get($memcached, $key) : memcached_get($memcached, $key);
}
break;
case 'eaccelerator':
// Again, eAccelerator.
if (function_exists('eaccelerator_get')) {
$value = eaccelerator_get($key);
}
break;
case 'mmcache':
// The older, but ever-stable, Turck MMCache...
if (function_exists('mmcache_get')) {
$value = mmcache_get($key);
}
break;
case 'apc':
case 'apcu':
// This is the free APC or APCu from PECL.
if (function_exists('apc_fetch')) {
$value = apc_fetch($key . 'elkarte');
}
break;
case 'zend':
// Zend's pricey stuff.
if (function_exists('zend_shm_cache_fetch')) {
$value = zend_shm_cache_fetch('ELK::' . $key);
} elseif (function_exists('output_cache_get')) {
$value = output_cache_get($key, $ttl);
}
break;
case 'xcache':
if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
$value = xcache_get($key);
}
break;
default:
// Otherwise it's ElkArte data!
if (file_exists(CACHEDIR . '/data_' . $key . '.php') && filesize(CACHEDIR . '/data_' . $key . '.php') > 10) {
// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
@(include CACHEDIR . '/data_' . $key . '.php');
if (!empty($expired) && isset($value)) {
@unlink(CACHEDIR . '/data_' . $key . '.php');
unset($value);
}
}
break;
}
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count]['t'] = microtime(true) - $st;
$cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
}
if (function_exists('call_integration_hook') && isset($value)) {
call_integration_hook('cache_get_data', array($key, $ttl, $value));
}
return empty($value) ? null : @unserialize($value);
}
示例8: init__caches
/**
* Standard code module initialisation function.
*/
function init__caches()
{
global $CACHE_ON;
$CACHE_ON = NULL;
global $MEM_CACHE, $SITE_INFO;
$MEM_CACHE = NULL;
$use_memcache = array_key_exists('use_mem_cache', $SITE_INFO) && $SITE_INFO['use_mem_cache'] == '1';
// Default to off because badly configured caches can result in lots of very slow misses and lots of lost sessions || ((!array_key_exists('use_mem_cache',$SITE_INFO)) && ((function_exists('xcache_get')) || (function_exists('wincache_ucache_get')) || (function_exists('apc_fetch')) || (function_exists('eaccelerator_get')) || (function_exists('mmcache_get'))));
if ($use_memcache && $GLOBALS['IN_MINIKERNEL_VERSION'] != 1) {
if (class_exists('Memcache')) {
require_code('caches_memcache');
$MEM_CACHE = new memcachecache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS = array();
$ECACHE_OBJECTS = $MEM_CACHE->get(get_file_base() . 'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS === NULL) {
$ECACHE_OBJECTS = array();
}
} elseif (function_exists('apc_fetch')) {
require_code('caches_apc');
$MEM_CACHE = new apccache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS = apc_fetch(get_file_base() . 'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS === false) {
$ECACHE_OBJECTS = array();
}
} elseif (function_exists('eaccelerator_put') || function_exists('mmcache_put')) {
require_code('caches_eaccelerator');
$MEM_CACHE = new eacceleratorcache();
global $ECACHE_OBJECTS;
if (function_exists('eaccelerator_get')) {
$ECACHE_OBJECTS = eaccelerator_get(get_file_base() . 'ECACHE_OBJECTS');
}
if (function_exists('mmcache_get')) {
$ECACHE_OBJECTS = mmcache_get(get_file_base() . 'ECACHE_OBJECTS');
}
if ($ECACHE_OBJECTS === NULL) {
$ECACHE_OBJECTS = array();
}
} elseif (function_exists('xcache_get')) {
require_code('caches_xcache');
$MEM_CACHE = new xcache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS = xcache_get(get_file_base() . 'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS === false) {
$ECACHE_OBJECTS = array();
}
} elseif (function_exists('wincache_ucache_get')) {
require_code('caches_wincache');
$MEM_CACHE = new wincache();
global $ECACHE_OBJECTS;
$ECACHE_OBJECTS = wincache_ucache_get(get_file_base() . 'ECACHE_OBJECTS');
if ($ECACHE_OBJECTS === false) {
$ECACHE_OBJECTS = array();
}
} elseif (file_exists(get_custom_file_base() . '/persistant_cache/') && $GLOBALS['DEV_MODE']) {
require_code('caches_filesystem');
require_code('files');
$MEM_CACHE = new filecache();
}
}
}
示例9: cache_get_data
/**
* Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
* - It may often "miss", so shouldn't be depended on.
* - It supports the same as cache_put_data().
*
* @param string $key
* @param int $ttl = 120
* @return string
*/
function cache_get_data($key, $ttl = 120)
{
global $boardurl, $sourcedir, $modSettings, $memcached;
global $cache_hits, $cache_count, $db_show_debug, $cachedir;
global $cache_accelerator, $cache_enable;
if (empty($cache_enable)) {
return;
}
$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count] = array('k' => $key, 'd' => 'get');
$st = microtime();
}
$key = md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-' . strtr($key, ':/', '-_');
switch ($cache_accelerator) {
case 'memcache':
// Okay, let's go for it memcached!
if ((function_exists('memcache_get') || function_exists('memcached_get')) && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') {
// Not connected yet?
if (empty($memcached)) {
get_memcached_server();
}
if (!$memcached) {
return null;
}
$value = function_exists('memcache_get') ? memcache_get($cache['connection'], $key) : memcached_get($cache['connection'], $key);
}
break;
case 'eaccelerator':
// Again, eAccelerator.
if (function_exists('eaccelerator_get')) {
$value = eaccelerator_get($key);
}
break;
case 'mmcache':
// The older, but ever-stable, Turck MMCache...
if (function_exists('mmcache_get')) {
$value = mmcache_get($key);
}
break;
case 'apc':
// This is the free APC from PECL.
if (function_exists('apc_fetch')) {
$value = apc_fetch($key . 'smf');
}
break;
case 'zend':
// Zend's pricey stuff.
if (function_exists('zend_shm_cache_fetch')) {
$value = zend_shm_cache_fetch('SMF::' . $key, $ttl);
} elseif (function_exists('output_cache_get')) {
$value = output_cache_get($key, $ttl);
}
break;
case 'xcache':
if (function_exists('xcache_get') && ini_get('xcache.var_size') > 0) {
$value = xcache_get($key);
}
break;
default:
// Otherwise it's SMF data!
if (file_exists($cachedir . '/data_' . $key . '.php') && filesize($cachedir . '/data_' . $key . '.php') > 10) {
// php will cache file_exists et all, we can't 100% depend on its results so proceed with caution
@(include $cachedir . '/data_' . $key . '.php');
if (!empty($expired) && isset($value)) {
@unlink($cachedir . '/data_' . $key . '.php');
unset($value);
}
}
break;
}
if (isset($db_show_debug) && $db_show_debug === true) {
$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
$cache_hits[$cache_count]['s'] = isset($value) ? strlen($value) : 0;
}
if (function_exists('call_integration_hook')) {
call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
}
return empty($value) ? null : @unserialize($value);
}