{"id":16440610,"url":"https://github.com/darrynten/any-cache","last_synced_at":"2025-03-21T04:33:37.167Z","repository":{"id":52421957,"uuid":"80923991","full_name":"darrynten/any-cache","owner":"darrynten","description":"Adapter designed to add Framework Agnosticism for Caching within PHP Packages.","archived":false,"fork":false,"pushed_at":"2021-04-29T19:13:41.000Z","size":40,"stargazers_count":8,"open_issues_count":9,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T21:42:18.971Z","etag":null,"topics":["adapter","agnostic-implementation","agnostic-to-frameworks","caching","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darrynten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-04T14:19:40.000Z","updated_at":"2020-07-27T19:22:48.000Z","dependencies_parsed_at":"2022-08-21T05:40:27.084Z","dependency_job_id":null,"html_url":"https://github.com/darrynten/any-cache","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darrynten%2Fany-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darrynten%2Fany-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darrynten%2Fany-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darrynten%2Fany-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darrynten","download_url":"https://codeload.github.com/darrynten/any-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244738835,"owners_count":20501923,"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":["adapter","agnostic-implementation","agnostic-to-frameworks","caching","php"],"created_at":"2024-10-11T09:12:33.651Z","updated_at":"2025-03-21T04:33:36.906Z","avatar_url":"https://github.com/darrynten.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## any-cache\n\n![Travis Build Status](https://travis-ci.org/darrynten/any-cache.svg?branch=master)\n![StyleCI Status](https://styleci.io/repos/80923991/shield?branch=master)\n[![codecov](https://codecov.io/gh/darrynten/any-cache/branch/master/graph/badge.svg)](https://codecov.io/gh/darrynten/any-cache)\n![Packagist Version](https://img.shields.io/packagist/v/darrynten/any-cache.svg)\n![MIT License](https://img.shields.io/github/license/darrynten/any-cache.svg)\n\nAdapter designed to add Framework Agnosticism for Caching within PHP Packages.\n\nSupports PHP 5.6+\n\n### Install\n\n```bash\ncomposer require darrynten/any-cache\n```\n\n### Goal\n\nAllow package developers to use whichever caching mechanisms are native\nto whichever framework it is installed in via a simple interface.\n\nCan be passed an artifact, but can also autodetect its host framework.\n\nPassing in takes precedence and allows developers to use a specific\nframework but with a totally different cache library or configuration.\n\n### Details\n\nPackage creators can include `AnyCache` in their packages and leverage\nsupported host framework native caching capabilities.\n\n`AnyCache` auto-detects its host framework and does not require any\nextra configuration, although it also allows passing in a desired cache.\n\nIf none is provided or if there is no caching available, then a local\ntemporary `ArrayCache` is created and will be used by default. This is\ntransient and not persistent.\n\nThis allows you to not have any additional caching requirements in your\npackages while allowing you  to leverage whichever caching constructs \nare already in place.\n\n### Supported Frameworks\n\n- [x] Temporary Array (default)\n- [x] Laravel\n- [x] Symfony\n- [x] Doctrine\n- [x] Psr6\n- [ ] CodeIgniter (partially complete)\n- [ ] ...\n\n### Supported Cache Calls\n\n- [x] get ($key, $default)\n- [x] set ($key, $value, $time)\n- [x] has ($key)\n- [x] pull ($key)\n- [ ] forever ($key, $value)\n- [ ] ...\n\n### Provides\n\nCreate a new instance.\n\n```php\nuse DarrynTen\\AnyCache;\n\n$this-\u003ecache = new AnyCache()\n```\n\nCall\n\n```php\n$key = 'foo';\n$value = 'bar';\n$time = 60;\n\n// Set a value\n$this-\u003ecache()-\u003eset($key, $value, $time);\n\n// Get a cached value\n$result = $this-\u003ecache()-\u003eget($key);\n\n// Check if a key exists\nif ($this-\u003ecache-\u003ehas($key)) {\n  //\n}\n\n// Get and unset\n$result = $this-\u003ecache()-\u003epull($key);\n```\n\n### Notes\n\nThe CodeIgniter support is not complete, and it does not auto-detect\nthis framework at this time.\n\n### Missing Tests\n\nThe Laravel tests are not 100% complete, there is an issue with\ntesting the Cache Facade on the `get` method.\n\nThe factory does not have unit test coverage at this point in time.\n\nThe main class is also not tested yet.\n\n#### Acknowledgments\n\n* [Marcel Pociot](https://github.com/mpociot) and his [Botman Project](https://github.com/mpociot/botman)\nfor the original idea and implementation.\n* [Alexander Marinov](https://github.com/ssaki) for his amazing skills.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarrynten%2Fany-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarrynten%2Fany-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarrynten%2Fany-cache/lists"}