riste / repository
Allow you to easily cache laravel models and retrieve from laravel's cache by extending AbstractRepository
Requires
- php: ^8.4
- laravel/framework: ^12.0
Requires (Dev)
This package is auto-updated.
Last update: 2026-04-14 16:38:02 UTC
README
INSTALLATION: composer require riste/repository:dev-main
Caching models, example:
class UserRepository extends AbstractRepository { private string $key = "_users"; public function getKey():string { return $this->key; } public function setKey(string $key):void { $this->$key = $key; } }
Finally, if i want to save/update my current user eloquent model i will call:
$userRepo = new UserRepository(); $userModel = User::find(1); $userRepo->addOrUpdate($userModel, 1); // where second parameter is TTL cache in hours
// If i need to search trough cache i will call findMany method $userRepo->findMany(["name" => "Riste"]); // Will look through cache where column is name and value Riste in case insensitive and will return array items of eloquent models that matches name Riste.