{"id":37234188,"url":"https://github.com/xinningsu/laravel-easy-cache","last_synced_at":"2026-01-15T03:57:55.758Z","repository":{"id":57084398,"uuid":"327871752","full_name":"xinningsu/laravel-easy-cache","owner":"xinningsu","description":"Easy way to cache the result of service method as demand.","archived":false,"fork":false,"pushed_at":"2021-03-06T03:16:15.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T02:36:19.185Z","etag":null,"topics":["cache","easy-cache","laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xinningsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-08T10:31:50.000Z","updated_at":"2021-03-06T03:16:17.000Z","dependencies_parsed_at":"2022-08-24T14:59:11.012Z","dependency_job_id":null,"html_url":"https://github.com/xinningsu/laravel-easy-cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/xinningsu/laravel-easy-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinningsu%2Flaravel-easy-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinningsu%2Flaravel-easy-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinningsu%2Flaravel-easy-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinningsu%2Flaravel-easy-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xinningsu","download_url":"https://codeload.github.com/xinningsu/laravel-easy-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinningsu%2Flaravel-easy-cache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","easy-cache","laravel"],"created_at":"2026-01-15T03:57:55.199Z","updated_at":"2026-01-15T03:57:55.753Z","avatar_url":"https://github.com/xinningsu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Easy Cache\n\nEasy way to cache the result of a service method on demand.\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n[![Build Status](https://api.travis-ci.org/xinningsu/laravel-easy-cache.svg?branch=master)](https://travis-ci.org/xinningsu/laravel-easy-cache)\n[![Coverage Status](https://coveralls.io/repos/github/xinningsu/laravel-easy-cache/badge.svg?branch=master)](https://coveralls.io/github/xinningsu/laravel-easy-cache)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/xinningsu/laravel-easy-cache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/xinningsu/laravel-easy-cache)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/xinningsu/laravel-easy-cache/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/g/xinningsu/laravel-easy-cache)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xinningsu_laravel-easy-cache\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=xinningsu_laravel-easy-cache)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=xinningsu_laravel-easy-cache\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=xinningsu_laravel-easy-cache)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=xinningsu_laravel-easy-cache\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=xinningsu_laravel-easy-cache)\n[![Maintainability](https://api.codeclimate.com/v1/badges/18669386ce65532b228f/maintainability)](https://codeclimate.com/github/xinningsu/laravel-easy-cache/maintainability)\n\n# Installation\n\nRequire this package with composer. \n\n```\ncomposer require xinningsu/laravel-easy-cache\n\n```\n\n[Optional] Copy `config/easy-cache.php` of this package to `config/easy-cache.php` under laravel project and custom it. see [Global Configuration](#global-configuration) for more detail.\n\n\n# Usage\n\nUse EasyCache trait in a service class\n\n\n```php\nclass News\n{\n    use \\Sulao\\EasyCache\\EasyCache;\n\n    public function getTopNews($limit = 5)\n    {\n        $news = [\n            ['id' =\u003e 1, 'title' =\u003e 'news 1'],\n            ['id' =\u003e 2, 'title' =\u003e 'news 2'],\n            ['id' =\u003e 3, 'title' =\u003e 'news 3'],\n            ['id' =\u003e 4, 'title' =\u003e 'news 4'],\n            ['id' =\u003e 5, 'title' =\u003e 'news 5'],\n        ];\n\n        return array_slice($news, 0, $limit);\n    }\n}\n\n```\n\nNow the result of the service method can be cached on demand.\n\n```php\n$news = new News();\n\n// without caching\n$topNews = $news-\u003egetTopNews(2);\n\n// cache it with default configuration, ttl: 3600,\n// key: serialize class name, method name and parameters as cache key,\n// store: laravel default cache store\n// see Global Configuration below to custom default configuration.\n$topNews = $news-\u003ecache()-\u003egetTopNews(2);\n\n// or specify the ttl\n$topNews = $news-\u003ecache(300)-\u003egetTopNews(2);\n\n// specify the ttl and cache key,\n// please notice that the cache key has to be specified if there is\n// a closure in parameters, because closure can not be serialized.\n$topNews = $news-\u003ecache(300, 'cache-key')-\u003egetTopNews(2);\n\n// specify ttl, cache key and store,\n// store is the store defined in laravel config/cache.php\n$topNews = $news-\u003ecache(300, 'cache-key', 'array')-\u003egetTopNews(2);\n```\n\n\n# Global Configuration\n\nIf you want custom global config, copy config/easy-cache.php of this package to config/easy-cache.php under your laravel project.\n\n```php\nreturn [\n    // If the ttl parameter is not specified when calling cache method,\n    // then use this one, default value is 3600.\n    'ttl' =\u003e 3600,\n    \n    // Value can be the store defined in config/cache.php of laravel project,\n    // such as memcached, redis ... If null, using laravel default cache store.\n    'store' =\u003e null,\n\n    // This prefix will be added to the front of each cache key, so it can\n    // easily refresh the whole cache by changing this. default value is null.\n    'prefix' =\u003e null,\n\n    // If this specified, the caches in the page can be refreshed via query string,\n    // see Refresh Page Cache below.\n    'refresh_key' =\u003e null,\n];\n\n```\n\n# Refresh Page Cache\n\n\nFirstly have to defined `refresh_key` in [config/easy-cache.php](#global-configuration), such as\n\n```\n    'refresh_key' =\u003e 'clear_cache',\n```\n\nThen open the page and add the query string like this\n\n```\nhttp://localhots/?clear_cache=1\n```\n\nWill refresh all the caches of that page, notice that just the caches of the page, not all the caches in the store.\n\n# License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxinningsu%2Flaravel-easy-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxinningsu%2Flaravel-easy-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxinningsu%2Flaravel-easy-cache/lists"}