本文整理汇总了PHP中source\LuLu::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP LuLu::getCache方法的具体用法?PHP LuLu::getCache怎么用?PHP LuLu::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source\LuLu
的用法示例。
在下文中一共展示了LuLu::getCache方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenusByCategory
public static function getMenusByCategory($category, $fromCache = true)
{
$cachekey = self::CachePrefix . $category;
$values = $fromCache ? LuLu::getCache($cachekey) : false;
if ($values === false) {
$values = self::getArrayTreeInternal($category, 0, 0);
LuLu::setCache($cachekey, $values);
}
return $values;
}
示例2: getModel
public static function getModel($id, $fromCache = true)
{
$cacheKey = self::CachePrefix . $id;
$value = $fromCache ? LuLu::getCache($cacheKey) : false;
if ($value === false) {
$value = Config::findOne(['id' => $id]);
if ($value !== null) {
LuLu::setCache($cacheKey, $value);
}
}
return $value;
}
示例3: getTaxonomyById
public static function getTaxonomyById($id, $fromCache = true)
{
if ($id < 0 || empty($id)) {
return null;
}
$cacheKey = self::CachePrefix . $id;
$value = $fromCache ? LuLu::getCache($cacheKey) : false;
if ($value === false) {
$value = self::findOne(['id' => $id]);
if ($value !== null) {
LuLu::setCache($cacheKey, $value);
}
}
return $value;
}
示例4: getPermissionsByRole
public function getPermissionsByRole($role, $fromCache = true)
{
$cacheKey = self::CachePrefix . $role;
$value = $fromCache ? LuLu::getCache($cacheKey) : false;
if ($value === false) {
$query = new Query();
$query->select(['p.id', 'p.category', 'p.name', 'p.description', 'p.form', 'p.default_value', 'p.rule', 'p.sort_num', 'r.role', 'r.value']);
$query->from(['p' => $this->permissionTable, 'r' => $this->relationTable]);
$query->where('r.permission=p.id');
$query->andWhere(['r.role' => $role]);
$rows = $query->all();
$value = $this->convertPermissionValue($rows);
LuLu::setCache($cacheKey, $value);
}
return $value;
}
示例5: getData
public static function getData($code, $other = [], $fromCache = true)
{
$cacheKey = self::CachePrefix . $code;
$values = $fromCache ? LuLu::getCache($cacheKey) : false;
if ($values === false) {
$fragment = self::findOne(['code' => $code]);
if ($fragment == null) {
return [];
}
$query = $fragment->type === 1 ? Fragment1Data::find() : Fragment2Data::find();
$query->where(['fragment_id' => $fragment->id, 'status' => 1]);
$query->orderBy('sort_num asc');
$values = $query->all();
LuLu::setCache($cacheKey, $values);
}
$offset = isset($other['offset']) ? $other['offset'] : 0;
$limit = isset($other['limit']) ? $other['limit'] : count($values) - $offset;
return array_slice($values, $offset, $limit, true);
}