本文整理汇总了PHP中AMPSystem_Lookup::cache_key方法的典型用法代码示例。如果您正苦于以下问题:PHP AMPSystem_Lookup::cache_key方法的具体用法?PHP AMPSystem_Lookup::cache_key怎么用?PHP AMPSystem_Lookup::cache_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMPSystem_Lookup
的用法示例。
在下文中一共展示了AMPSystem_Lookup::cache_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AMP_lookup_clear_cached
function AMP_lookup_clear_cached($type, $instance_var = null)
{
//delete from memcache
require_once "AMP/System/Lookups.inc.php";
$key = AMPSystem_Lookup::cache_key($type, $instance_var);
AMP_cache_delete($key);
//clear existing in-memory copy
/*
$lookup_types = array( 'AMPSystem_Lookup' => 'AMPSystemLookup_',
'AMPContent_Lookup' => 'AMPContentLookup_',
'FormLookup' => 'FormLookup_');
$instance = AMP_to_camelcase( $lookup_type );
$value = false;
foreach( $lookup_types as $base_type => $prefix ) {
if ( !class_exists( $prefix . ucfirst( $instance ))) continue;
call_user_func_array( array( $base_type, 'instance'), array( $instance, $lookup_var, str_replace( '_', '', $prefix), true ));
}
*/
}
示例2: AMP_get_cache
function &instance($type, $instance_var = null, $lookup_baseclass = "AMPSystemLookup", $clear_existing = false)
{
static $lookup_set = false;
static $cache = false;
$empty_value = false;
if (!$cache) {
$cache = AMP_get_cache();
}
$req_class = $lookup_baseclass . '_' . ucfirst($type);
if (!class_exists($req_class)) {
trigger_error(sprintf(AMP_TEXT_ERROR_LOOKUP_NOT_FOUND, $req_class));
return $empty_value;
}
if (!isset($instance_var)) {
if ($clear_existing) {
unset($lookup_set[$type]);
return $empty_value;
}
//standard lookup
if (!isset($lookup_set[$type])) {
$lookup_cache_key = AMPSystem_Lookup::cache_key($type, $instance_var);
$cached_lookup = AMP_cache_get($lookup_cache_key);
if (!($cached_lookup && (!method_exists($cached_lookup, 'allow_cache') || $cached_lookup->allow_cache()))) {
$lookup_set[$type] = new $req_class();
if (!method_exists($lookup_set[$type], 'allow_cache') || $lookup_set[$type]->allow_cache()) {
AMP_cache_set($lookup_cache_key, $lookup_set[$type]);
}
} else {
$lookup_set[$type] = $cached_lookup;
}
}
} else {
//instanced lookup
if (!isset($lookup_set[$type])) {
$lookup_set[$type] = array();
}
if ($clear_existing) {
unset($lookup_set[$type][$instance_var]);
return $empty_value;
}
if (!isset($lookup_set[$type][$instance_var])) {
$lookup_cache_key = AMPSystem_Lookup::cache_key($type, $instance_var);
$cached_lookup = AMP_cache_get($lookup_cache_key);
if (!$cached_lookup) {
$lookup_set[$type][$instance_var] = new $req_class($instance_var);
AMP_cache_set($lookup_cache_key, $lookup_set[$type][$instance_var]);
} else {
$lookup_set[$type][$instance_var] = $cached_lookup;
}
}
return $lookup_set[$type][$instance_var]->dataset;
}
//AMP_cache_set( AMP_CACHE_TOKEN_LOOKUP . 'Master__' . AMP_SYSTEM_USER_ID, $lookup_set );
return $lookup_set[$type]->dataset;
}