{"id":15579665,"url":"https://github.com/schickling/laravel-cash","last_synced_at":"2025-04-24T01:28:32.689Z","repository":{"id":13151131,"uuid":"15833717","full_name":"schickling/laravel-cash","owner":"schickling","description":"Simple to use cache layer for your laravel application using memcached \u0026 nginx.","archived":false,"fork":false,"pushed_at":"2014-02-05T11:41:16.000Z","size":631,"stargazers_count":33,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T05:41:10.581Z","etag":null,"topics":[],"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/schickling.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":"2014-01-12T00:36:31.000Z","updated_at":"2024-10-29T14:30:47.000Z","dependencies_parsed_at":"2022-08-25T20:21:55.306Z","dependency_job_id":null,"html_url":"https://github.com/schickling/laravel-cash","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Flaravel-cash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Flaravel-cash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Flaravel-cash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schickling%2Flaravel-cash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schickling","download_url":"https://codeload.github.com/schickling/laravel-cash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250543468,"owners_count":21447904,"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":[],"created_at":"2024-10-02T19:20:28.259Z","updated_at":"2025-04-24T01:28:32.672Z","avatar_url":"https://github.com/schickling.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"laravel-cash [![Build Status](https://travis-ci.org/schickling/laravel-cash.png?branch=master)](https://travis-ci.org/schickling/laravel-cash) [![Coverage Status](https://coveralls.io/repos/schickling/laravel-cash/badge.png)](https://coveralls.io/r/schickling/laravel-cash) [![Total Downloads](https://poser.pugx.org/schickling/laravel-cash/downloads.png)](https://packagist.org/packages/schickling/laravel-cash)\n============\n\nSimple to use cache layer for your laravel application using memcached \u0026 nginx. ~400% faster response times.\n\n## How it works\n\nThe packages caches the responses to `GET` requests in memcached using the URL as key. Any further requests get served the cached content by nginx directly without running PHP. Writing actions can easily invalidate the cache.\n\n### Features\n\n* Easy to setup and use\n* Self defined invalidation rules\n* Automatic cache refilling\n* Cache warmup\n\n### Dependencies\n* Laravel 4.1\n* nginx ([installation guide](https://github.com/schickling/laravel-cash/blob/master/doc/NGINX.md))\n* memcached \u0026\u0026 PHP memcached extension ([installation guide](https://github.com/schickling/laravel-cash/blob/master/doc/MEMCACHED.md))\n\n## Quick setup\n\n1. Add the following to your composer.json and run `composer update`\n\n    ```json\n    {\n        \"require\": {\n            \"schickling/laravel-cash\": \"dev-master\"\n        }\n    }\n    ```\n\n2. Add `Schickling\\Cash\\CashServiceProvider` to your config/app.php\n\n3. Ajust your nginx vhost ([more configurations](https://github.com/schickling/laravel-cash/blob/master/doc/NGINX.md))\n\n    ```nginx\n    upstream memcached {\n        server 127.0.0.1:11211;\n        keepalive 1024;\n    }\n\n    upstream laravel {\n        server 127.0.0.1:9999;\n    }\n\n    server {\n        listen *:80;\n        server_name myapp.dev;\n\n        root /path/to/your/public;\n        index index.php;\n\n        rewrite ^/(.*)$ /index.php?/$1 last;\n\n        location ~ \\.php$ {\n            default_type \"application/json\";\n            if ($request_method = GET) {\n                set $memcached_key laravel:$request_uri;\n                memcached_pass laravel;\n                error_page 404 502 = @nocache;\n            }\n            if ($request_method != GET) {\n                fastcgi_pass laravel;\n            }\n        }\n\n        location @nocache {\n            fastcgi_pass laravel;\n        }\n    }\n    ```\n\n## Usage\n\n### Add cache filter to routes\nAdd the `'after' =\u003e 'cash'` filter to `GET` routes you want to be cached. Works also for groups of routes.\n\n```php\nRoute::get('users', array('after' =\u003e 'cash', function()\n{\n\treturn User::all();\n}));\n```\n\n### Define invalidation rules\n\nAdd rules of the following syntax in your `routes.php` file. The `$routeToInvalidate` parameter may be a string or an array and describe always `GET` routes.\n```php\nCash::rule($httpMethod, $triggerRoute, $routesToInvalidate);\n```\n\nLet's say you have a cached `GET users` route to retrieve all users and a `POST users` route to create a new user. Your goal is to invalidate the `GET users` cache if a new user was created.\n\n```php\nCash::rule('POST', 'users', 'users');\n```\n\n##### Multiple route caches\n```php\nCash::rule('POST', 'users', array('users', 'premium/users'));\n```\n\n##### Dynamic rules\n\n###### Dynamic trigger routes\n```php\nCash::rule('POST', 'users/.*/photos', 'photos');\n```\n\n###### Dynamic invalidation routes\n```php\nCash::rule('POST', 'photos', 'photos/*');\n```\n\n\n### Flush cache\nSimply restart memcached.\n\n\n## Coming soon (please contribute a [pull request](https://github.com/schickling/laravel-cash/compare/))\n\n* Support for named routes\n* Support for rules in route group scope\n* More precise hierarchic invalidation\n* Apache support\n* Memcache support\n* Cache warmup\n* Individual cache rewarmup\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschickling%2Flaravel-cash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschickling%2Flaravel-cash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschickling%2Flaravel-cash/lists"}