Skip to content

Commit

Permalink
Merge pull request #226 from kodeine/revert-216-1.0
Browse files Browse the repository at this point in the history
Revert "Add tags to the cache to easily purge ACL cache"
  • Loading branch information
kodeine authored Feb 12, 2018
2 parents dc1e7e7 + 3555573 commit 6c9d73e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Kodeine/Acl/Models/Eloquent/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function users()
*/
public function getPermissions()
{
return \Cache::tags(config('acl.cacheTags', []))->remember(
return \Cache::remember(
'acl.getPermissionsInheritedById_'.$this->id,
config('acl.cacheMinutes'),
function () {
Expand Down
16 changes: 6 additions & 10 deletions src/Kodeine/Acl/Traits/HasPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function permissions()
public function getPermissions()
{
// user permissions overridden from role.
$permissions = \Cache::tags(config('acl.cacheTags', []))->remember(
'acl.getPermissionsById_' . $this->id,
$permissions = \Cache::remember(
'acl.getPermissionsById_'.$this->id,
config('acl.cacheMinutes'),
function () {
return $this->getPermissionsInherited();
Expand All @@ -48,14 +48,10 @@ function () {
// true values.
foreach ($this->roles as $role) {
foreach ($role->getPermissions() as $slug => $array) {
if (array_key_exists($slug, $permissions)) {
if ( array_key_exists($slug, $permissions) ) {
foreach ($array as $clearance => $value) {
if (! array_key_exists($clearance, $permissions[$slug])) {
if( !array_key_exists( $clearance, $permissions[$slug] ) ) {
! $value ?: $permissions[$slug][$clearance] = true;
} else {
if ($permissions[$slug][$clearance] != $value) {
$permissions[$slug][$clearance] = $value;
}
}
}
} else {
Expand All @@ -78,7 +74,7 @@ public function can($permission, $operator = null)
{
// user permissions including
// all of user role permissions
$merge = \Cache::tags(config('acl.cacheTags', []))->remember(
$merge = \Cache::remember(
'acl.getMergeById_'.$this->id,
config('acl.cacheMinutes'),
function () {
Expand Down Expand Up @@ -197,4 +193,4 @@ protected function parsePermissionId($permission)

return (int) $permission;
}
}
}
4 changes: 2 additions & 2 deletions src/Kodeine/Acl/Traits/HasRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function roles()
{
$model = config('acl.role', 'Kodeine\Acl\Models\Eloquent\Role');

return $this->belongsToMany($model)->withTimestamps()->orderBy('roles.created_at');
return $this->belongsToMany($model)->withTimestamps();
}

/**
Expand All @@ -36,7 +36,7 @@ public function roles()
*/
public function getRoles()
{
$this_roles = \Cache::tags(config('acl.cacheTags', []))->remember(
$this_roles = \Cache::remember(
'acl.getRolesById_'.$this->id,
config('acl.cacheMinutes'),
function () {
Expand Down
7 changes: 0 additions & 7 deletions src/config/acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,4 @@
*/

'cacheMinutes' => 1,

/**
* Cache tags
*
* All cached entries are tagged to easily purge them on demand
*/
'cacheTags' => ['acl']
];

0 comments on commit 6c9d73e

Please sign in to comment.