RobTrehy / LaravelUserPreferences

A package for Laravel to store user preferences for your project
MIT License
2 stars 0 forks source link

Added use of cache #4

Closed fefo-p closed 3 years ago

fefo-p commented 3 years ago

Using cache avoids DB queries when nothing has changed. \ We flush the cache inside save method whenever a value has changed

fefo-p commented 3 years ago

A comment should be added to the README.md stating that to be able to use cache you'd have to set the driver in the .env file.

CACHE_DRIVER=file

If using the database driver, then change the .env CACHE_DRIVER var to

CACHE_DRIVER=database

and migrate the DB

php artisan cache:table
php artisan migrate
RobTrehy commented 3 years ago

Please update the readme within this PR, then I'll merge it.

theVannu commented 3 years ago

Can I suggest to create 2 config's variables (prefix and suffix) instead of use this: 'user-'.Auth::id().'-preferences', so we can customize the key used by the cache. What do you think about it?

RobTrehy commented 3 years ago

This has been updated and merged with the customisable config for cache key prefix/suffix as suggested by @theVannu

Release 2.1.0