예제 #1
0
 public static function testModel($returnType = 'array', $refresh = false, $autoset = true)
 {
     $cachekey = 'test-array-model';
     if ($refresh) {
         BCacheHelper::delete($cachekey);
     }
     $data = self::get($cachekey, function () {
         $users = User::model()->findAll(array('condition' => 'isdelete=0', 'limit' => 10));
         $users = BArrayHelper::getModelIndexArray($users, 'userid', BCacheHelper::getPreChar());
         return $users;
     }, $autoset);
     return $data;
 }
예제 #2
0
 public static function getTokens($returnType = 'array', $refresh = false, $autoset = true, $condition = null)
 {
     if ($refresh) {
         BCacheHelper::delete(self::CACHETYPE_TOKENS);
     }
     $data = self::get(self::CACHETYPE_TOKENS, self::_getTokens(), $autoset);
     if (!empty($condition) && is_callable($condition)) {
         $data = array_filter($data, function ($v) use($condition) {
             return $condition($v);
         });
     }
     if ($returnType == 'model') {
         array_walk($data, function (&$v) {
             $v = BCacheHelper::getModel('AccessToken', $v);
         });
     }
     return $data;
 }