{"id":19476692,"url":"https://github.com/biurad/php-cache","last_synced_at":"2025-10-05T15:50:34.164Z","repository":{"id":43751852,"uuid":"222194883","full_name":"biurad/php-cache","owner":"biurad","description":"⏱ A library that provides an advanced caching system for PSR-6 and PSR-16, with an easy-to-use API for quick caching.","archived":false,"fork":false,"pushed_at":"2025-02-03T04:14:48.000Z","size":176,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T22:51:14.143Z","etag":null,"topics":["biurad","cache","doctrine-cache","php","psr-16","psr-6"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biurad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG-0.x.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"biurad","custom":["https://biurad.com/sponsor"]}},"created_at":"2019-11-17T04:04:13.000Z","updated_at":"2023-08-22T02:18:52.000Z","dependencies_parsed_at":"2024-11-10T19:41:50.137Z","dependency_job_id":null,"html_url":"https://github.com/biurad/php-cache","commit_stats":{"total_commits":143,"total_committers":5,"mean_commits":28.6,"dds":"0.19580419580419584","last_synced_commit":"cbfa4385a6cc2769daf9133cb653b5e8ab13e866"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fphp-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fphp-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fphp-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fphp-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biurad","download_url":"https://codeload.github.com/biurad/php-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250834171,"owners_count":21494922,"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":["biurad","cache","doctrine-cache","php","psr-16","psr-6"],"created_at":"2024-11-10T19:41:29.795Z","updated_at":"2025-10-05T15:50:29.114Z","avatar_url":"https://github.com/biurad.png","language":"PHP","funding_links":["https://patreon.com/biurad","https://biurad.com/sponsor"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# The Poakium Cache\n\n[![Latest Version](https://img.shields.io/packagist/v/biurad/cache?include_prereleases\u0026label=Latest\u0026style=flat-square)](https://packagist.org/packages/biurad/cache)\n[![Workflow Status](https://img.shields.io/github/actions/workflow/status/biurad/poakium/ci.yml?branch=master\u0026label=Workflow\u0026style=flat-square)](https://github.com/biurad/poakium/actions?query=workflow)\n[![Software License](https://img.shields.io/badge/License-BSD--3-brightgreen.svg?\u0026label=Poakium\u0026style=flat-square)](LICENSE)\n[![Maintenance Status](https://img.shields.io/maintenance/yes/2023?label=Maintained\u0026style=flat-square)](https://github.com/biurad/poakium)\n\n\u003c/div\u003e\n\n---\n\nA [PHP][1] library that provides a high-performance caching system for storing the results of expensive computations, database queries, or network requests. Supports both [PSR-6][2] and [PSR-16][3] caching standards.\n\n## 📦 Installation\n\nThis project requires [PHP][1] 7.2 or higher. The recommended way to install, is via [Composer][4]. Simply run:\n\n```bash\n$ composer require biurad/cache\n```\n\n## 📍 Quick Start\n\nOne of the key features of this library is its ability to cache the result of a callable or function, allowing for the caching of complex computations or database queries. Additionally, it includes a fallback load feature to ensure that the cached value is always fetched, even if it has expired from the cache.\n\nHere is an example of how to use the library using [symfony/cache][5]:\n\n```php\nuse Biurad\\Cache\\FastCache as Cache;\nuse Psr\\Cache\\CacheItemInterface;\nuse Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter;\n\n$storage = new PhpFilesAdapter(directory: __DIR__.'/cache');\n$cache = new Cache($storage);\n$cache-\u003esetCacheItem(\\Symfony\\Component\\Cache\\CacheItem::class);\n\n// The callable will only be executed on a cache miss.\n$value = $cache-\u003eload(\n    'my_cache_key',\n    static function (CacheItemInterface $item): CacheItemInterface {\n        $item-\u003eexpiresAfter(3600);\n\n        // ... do some HTTP request or heavy computations\n        $item-\u003eset('foobar');\n\n        return $item;\n    }\n);\n\necho $value; // 'foobar'\n\n// ... and to remove the cache key\n$cache-\u003edelete('my_cache_key');\n\n// cache the result of the function\n$ip = $cache-\u003ecall('gethostbyaddr', \"127.0.0.1\");\n\nfunction calculate(array $a, array $b): array {\n    $result = [];\n    foreach ($a as $i =\u003e $v) foreach ($v as $k =\u003e $m) $result[$i][$k] = $m + $b[$i][$k];\n\n    return $result;\n}\n\n$matrix = $cache-\u003ewrap('calculate');\n$result = $matrix([[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]) // [[8, 10, 12], [14, 16, 18]]\n\n// Caching the result of printable contents using PHP echo.\nif ($block = $cache-\u003estart($key)) {\n\t  ... printing some data ...\n\n\t  $block-\u003eend(); // save the output to the cache\n}\n```\n\n\u003e **NB:** The beta parameter found on cache methods default value is 1.0 and higher values mean earlier recompute. Set it to 0 to disable early recompute and set it to INF to force an immediate recompute:\n\n## 📓 Documentation\n\nIn-depth documentation on how to use this library can be found at [docs.biurad.com][6]. It is also recommended to browse through unit tests in the [tests](./tests/) directory.\n\n## 🙌 Sponsors\n\nIf this library made it into your project, or you interested in supporting us, please consider [donating][7] to support future development.\n\n## 👥 Credits \u0026 Acknowledgements\n\n- [Divine Niiquaye Ibok][8] is the author this library.\n- [All Contributors][9] who contributed to this project.\n\n## 📄 License\n\nPoakium Cache is completely free and released under the [BSD 3 License](LICENSE).\n\n[1]: https://php.net\n[2]: http://www.php-fig.org/psr/psr-6/\n[3]: http://www.php-fig.org/psr/psr-16/\n[4]: https://getcomposer.org\n[5]: https://github.com/symfony/cache\n[6]: https://docs.biurad.com/poakium/cache\n[7]: https://biurad.com/sponsor\n[8]: https://github.com/divineniiquaye\n[9]: https://github.com/biurad/php-cache/contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiurad%2Fphp-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiurad%2Fphp-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiurad%2Fphp-cache/lists"}