Esempio n. 1
0
        $feature = $feature->fetch(PDO::FETCH_ASSOC);
        $acl[$k]['feature_name'] = $feature['name'];
        $scope = $pdo->query("SELECT scope_id FROM rule WHERE aid={$v['aid']} AND role_id={$v['role_id']} AND model_id={$v['model_id']} AND feature_id={$v['feature_id']} ORDER BY scope_id ASC");
        $scope = $scope->fetchAll(PDO::FETCH_ASSOC);
        foreach ($scope as $vs) {
            $acl[$k]['scope'][] = $vs['scope_id'];
        }
        $unique[$k] = $appName . $v['role_id'] . $v['model_id'] . $v['feature_id'];
    }
    $unique = array_unique($unique);
    foreach ($unique as $k => $vu) {
        $rule[] = $acl[$k];
    }
    return $rule;
}
$m = new Mycached();
$m->addServers([['127.0.0.1', '11211']]);
print_r($m->getError());
$rules = $m->mem('rule');
if (!$rules) {
    echo ' it`s new rules!' . "\n";
    $m->mem('rule', getRules(), 10);
    $rules = $m->mem('rule');
} else {
    echo ' it`s the cache rules!' . "\n";
}
$str = '';
foreach ($rules as $v) {
    $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_app\t\thdr(X-App)\t\t" . $v['app'] . "\n";
    $str .= "acl app_" . $v['app'] . "_role_" . $v['role_id'] . "_" . $v['model_name'] . "_" . $v['feature_name'] . "_role\t\thdr(X-Role)\t\t" . $v['user'] . "\n";
    $scope_str = '';
Esempio n. 2
0
<?php

function autoload($class)
{
    require_once "./" . $class . ".php";
}
spl_autoload_register('autoload', true);
$m = new Mycached();
$m->addServers([['127.0.0.1', '11211']]);
if (empty($m->mem(array('key1', 'key2')))) {
    $m->mem(array('key1' => 'value1', 'key2' => 'value2'), 6);
    // 设置cache 6秒过期
    echo "this   is   new  data!\n";
} else {
    echo "this   is   cache  data!\n";
}
// $m->mem(array('key1','key2'),0); // 删除cache
print_r($m->mem(array('key1', 'key2')));
// 获得cache