{"id":15043568,"url":"https://github.com/authentikcanada/eloquent-cache","last_synced_at":"2025-04-14T07:08:03.723Z","repository":{"id":62489651,"uuid":"143887719","full_name":"AuthentikCanada/eloquent-cache","owner":"AuthentikCanada","description":"Easily cache your Laravel's Eloquent models.","archived":false,"fork":false,"pushed_at":"2023-04-21T17:05:43.000Z","size":62,"stargazers_count":57,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T07:07:57.399Z","etag":null,"topics":["cache","eloquent","laravel","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AuthentikCanada.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-07T14:47:53.000Z","updated_at":"2025-02-11T21:34:12.000Z","dependencies_parsed_at":"2024-09-21T04:04:26.729Z","dependency_job_id":"410f202a-f12b-46d3-9809-1f657479b708","html_url":"https://github.com/AuthentikCanada/eloquent-cache","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AuthentikCanada%2Feloquent-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AuthentikCanada%2Feloquent-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AuthentikCanada%2Feloquent-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AuthentikCanada%2Feloquent-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AuthentikCanada","download_url":"https://codeload.github.com/AuthentikCanada/eloquent-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837280,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","eloquent","laravel","php"],"created_at":"2024-09-24T20:49:16.691Z","updated_at":"2025-04-14T07:08:03.686Z","avatar_url":"https://github.com/AuthentikCanada.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Eloquent Cache\n\n\u003e Easily cache your Laravel's Eloquent models.\n\n[![Build Status](https://travis-ci.org/AuthentikCanada/eloquent-cache.svg?branch=master)](https://travis-ci.org/AuthentikCanada/eloquent-cache)\n[![Coverage Status](https://coveralls.io/repos/github/AuthentikCanada/eloquent-cache/badge.svg?branch=master)](https://coveralls.io/github/AuthentikCanada/eloquent-cache?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/authentik/eloquent-cache/v/stable.svg)](https://packagist.org/packages/authentik/eloquent-cache)\n[![Total Downloads](https://poser.pugx.org/authentik/eloquent-cache/downloads.svg)](https://packagist.org/packages/authentik/eloquent-cache)\n\n## Requirements\n\n- PHP \u003e= 7.2\n\n- Laravel 6 / 7 / 8\n\n## Installation\n\nInstall via [composer](https://getcomposer.org/) :\n\n`composer require authentik/eloquent-cache`\n\n## How it works\n\n- When Eloquent fetches models, the JSON representations of the model instances are cached.\n\n- Subsequently, when eloquent fetches a model by ID, the cached JSON will be converted back into an instance.\n\n## Usage\n\nUse the `Cacheable` trait in the models you want to cache.\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Authentik\\EloquentCache\\Cacheable;\n\nclass Category extends Model\n{\n    use Cacheable;\n\n\n    /*\n     * You can optionally override the following functions:\n     */\n    \n    // Time To Live in minutes (default value: 0 =\u003e no TTL)\n    public function getCacheTTL() {\n        return 60;\n    }\n\n    // default value: the lowercase name of the model\n    public function getCacheTagName() {\n        return 'cat';\n    }\n\n    // Cache busting will automatically invalidate the cache when model instances are updated or deleted.\n    // default value: true\n    public function isCacheBustingEnabled() {\n        return false;\n    }\n\n    // Whether or not to keep model instances in a static array cache\n    //  (useful to avoid querying the cache store/building instances from json multiple times)\n    // default value: true\n    public function isStaticCacheEnabled() {\n        return false;\n    }\n}\n```\n\n\u003e To manually cache a model instance, use the `cache` method.\n\n```php\nCategory::find(1)-\u003ecache();\n```\n\n\u003e To invalidate the cache for a model instance, use the `refresh` or `flush` method.\n\n```php\n$refreshedInstance = Category::find(1)-\u003erefresh();\n\n// or\n\nCategory::flush(Category::find(1));\n```\n\n\u003e To invalidate the cache for all instances of a model, use the `flush` method.\n\n```php\nCategory::flush();\n```\n\n## Changelog\n\n[Click Here](CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthentikcanada%2Feloquent-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauthentikcanada%2Feloquent-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauthentikcanada%2Feloquent-cache/lists"}