Skip to content

Commit

Permalink
Update README re: cache (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
drbyte authored and freekmurze committed Sep 2, 2017
1 parent e36ddb9 commit f89cf02
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,27 +608,35 @@ php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvid

And update the `models.role` and `models.permission` values

## Troubleshooting

### Cache
## Cache

If you manipulate permission/role data directly in the database instead of calling the supplied methods, then you will not see the changes reflected in the application, because role and permission data is cached to speed up performance.
Role and Permission data are cached to speed up performance.

To manually reset the cache for this package, run:
```bash
php artisan cache:forget spatie.permission.cache
```

When you use the supplied methods, such as the following, the cache is automatically reset for you:
When you use the supplied methods for manipulating roles and permissions, the cache is automatically reset for you:

```php
// see earlier in the README for how these methods work:
$user->assignRole('writer');
$user->removeRole('writer');
$user->syncRoles(params);
$role->givePermissionTo('edit articles');
$role->revokePermissionTo('edit articles');
$role->syncPermissions(params);
```

HOWEVER, if you manipulate permission/role data directly in the database instead of calling the supplied methods, then you will not see the changes reflected in the application unless you manually reset the cache.

### Manual cache reset
To manually reset the cache for this package, run:
```bash
php artisan cache:forget spatie.permission.cache
```

### Cache Identifier

TIP: If you are leveraging a caching service such as redis or memcached and there are other sites running on your server, you could run into cache clashes. It is prudent to set your own cache `prefix` in `/config/cache.php` for each application uniquely. This will prevent other applications from accidentally using/changing your cached data.


## Need a UI?

The package doesn't come with any screens out of the box, you should build that yourself. To get started check out [this extensive tutorial](https://scotch.io/tutorials/user-authorization-in-laravel-54-with-spatie-laravel-permission) by [Caleb Oki](http://www.caleboki.com/).
Expand Down

0 comments on commit f89cf02

Please sign in to comment.