Skip to content

Commit

Permalink
Merge pull request #14 from qeq66/master
Browse files Browse the repository at this point in the history
feat: 增加缓存且自动更新缓存
  • Loading branch information
leeqvip committed Dec 24, 2020
2 parents 291a8c2 + 24d0298 commit e36da7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ before_install:
install:
- travis_retry composer install --prefer-dist --dev --no-suggest --no-interaction

before_script:
- export XDEBUG_MODE=coverage

script:
- vendor/bin/phpunit --version
- mkdir -p build/logs
Expand Down
8 changes: 4 additions & 4 deletions src/adapter/DatabaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function savePolicyLine($ptype, array $rule)
foreach ($rule as $key => $value) {
$col['v'.strval($key).''] = $value;
}
$this->model->create($col);
$this->model->cache('tauthz')->save($col);
}

/**
Expand All @@ -57,7 +57,7 @@ public function savePolicyLine($ptype, array $rule)
*/
public function loadPolicy(Model $model): void
{
$rows = $this->model->select()->toArray();
$rows = $this->model->cache('tauthz')->select()->toArray();
foreach ($rows as $row) {
$line = implode(', ', array_filter(array_slice($row, 1), function ($val) {
return '' != $val && !is_null($val);
Expand Down Expand Up @@ -117,7 +117,7 @@ public function removePolicy(string $sec, string $ptype, array $rule): void
}

foreach ($instance->select() as $model) {
if ($model->delete()) {
if ($model->cache('tauthz')->delete()) {
++$count;
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public function removeFilteredPolicy(string $sec, string $ptype, int $fieldIndex
}

foreach ($instance->select() as $model) {
if ($model->delete()) {
if ($model->cache('tauthz')->delete()) {
++$count;
}
}
Expand Down

0 comments on commit e36da7f

Please sign in to comment.