-
Notifications
You must be signed in to change notification settings - Fork 60
Description
New Driver Ideas
This document outlines ideas for new storage drivers that could be added to the laravel-model-settings
package after the main driver-based refactoring is complete.
1. Generic Cache
Driver
-
What it is: A storage driver that uses Laravel's generic
Cache
facade instead of being tied to a specific implementation like Redis. -
How it works: This driver would use
Cache::get()
andCache::put()
to store the settings. The cache key would be generated based on the model's type and ID. -
Why it's useful: This would be a major improvement in flexibility. It would allow users to leverage any cache store supported by Laravel (Memcached, DynamoDB, Database, File, etc.) simply by updating their
config/cache.php
file. This makes the package far more adaptable to different application architectures.
2. Filesystem
Driver
-
What it is: A driver that stores model settings as individual JSON files on a configured filesystem disk.
-
How it works: It would use Laravel's
Storage
facade. The settings for aUser
with ID123
could be stored at a path likemodel_settings/users/123.json
. -
Why it's useful:
- Portability: Settings are plain text files that can be easily backed up or version-controlled.
- Simplicity: Requires no database or cache service.
- Human-Readable: Settings can be viewed and even edited directly in the filesystem.
3. Array
Driver (For Testing)
-
What it is: A non-persistent driver that only stores settings in a PHP array for the duration of a single request.
-
How it works: The driver uses a simple static array to hold settings. All data is lost once the request is finished.
-
Why it's useful: This is the perfect driver for automated testing (Pest/PHPUnit). It's extremely fast and ensures that tests run in isolation without needing to interact with a database or cache, preventing data from leaking between test runs.