{"id":14966448,"url":"https://github.com/yiisoft/cache-apcu","last_synced_at":"2025-08-19T02:43:05.512Z","repository":{"id":35061381,"uuid":"184578297","full_name":"yiisoft/cache-apcu","owner":"yiisoft","description":"Yii Cache Library - APCu Handler","archived":false,"fork":false,"pushed_at":"2025-07-10T09:46:25.000Z","size":119,"stargazers_count":13,"open_issues_count":3,"forks_count":7,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-08-08T12:51:19.592Z","etag":null,"topics":["apcu","cache","cache-storage","hacktoberfest","psr-16","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","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/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"],"polar":"yiisoft"}},"created_at":"2019-05-02T12:37:52.000Z","updated_at":"2025-07-10T09:46:29.000Z","dependencies_parsed_at":"2022-07-17T11:46:22.676Z","dependency_job_id":"f5d3a14b-05bf-4dbd-b629-e624d7e190a1","html_url":"https://github.com/yiisoft/cache-apcu","commit_stats":{"total_commits":76,"total_committers":15,"mean_commits":5.066666666666666,"dds":0.5526315789473684,"last_synced_commit":"e145814243f9c1d3572d692caaaf9a0c718c59db"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yiisoft/cache-apcu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-apcu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-apcu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-apcu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-apcu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/cache-apcu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-apcu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271092128,"owners_count":24697903,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["apcu","cache","cache-storage","hacktoberfest","psr-16","yii3"],"created_at":"2024-09-24T13:36:24.075Z","updated_at":"2025-08-19T02:43:05.476Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft","https://polar.sh/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Cache Library - APCu Handler\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/cache-apcu/v/stable.png)](https://packagist.org/packages/yiisoft/cache-apcu)\n[![Total Downloads](https://poser.pugx.org/yiisoft/cache-apcu/downloads.png)](https://packagist.org/packages/yiisoft/cache-apcu)\n[![Build status](https://github.com/yiisoft/cache-apcu/workflows/build/badge.svg)](https://github.com/yiisoft/cache-apcu/actions?query=workflow%3Abuild)\n[![Code Coverage](https://codecov.io/gh/yiisoft/cache-apcu/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/cache-apcu)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fcache-apcu%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/cache-apcu/master)\n[![static analysis](https://github.com/yiisoft/cache-apcu/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/cache-apcu/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/cache-apcu/coverage.svg)](https://shepherd.dev/github/yiisoft/cache-apcu)\n\nThis package uses the PHP [APCu](https://www.php.net/manual/book.apcu.php)\nextension and implements [PSR-16](https://www.php-fig.org/psr/psr-16/) cache.\n\nThis option can be considered as the fastest one when dealing with a cache for a\ncentralized thick application (e.g. one server, no dedicated load balancers, etc.).\n\n## Requirements\n\n- PHP 8.0 or higher.\n- `APCu` PHP extension.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/cache-apcu\n```\n\n## General usage\n\nThe package does not contain any additional functionality for interacting with the cache,\nexcept those defined in the [PSR-16](https://www.php-fig.org/psr/psr-16/) interface.\n\n```php\n$cache = new \\Yiisoft\\Cache\\Apcu\\ApcuCache();\n$parameters = ['user_id' =\u003e 42];\n$key = 'demo';\n\n// try retrieving $data from cache\n$data = $cache-\u003eget($key);\n\nif ($data === null) {\n    // $data is not found in cache, calculate it from scratch\n    $data = calculateData($parameters);\n    \n    // store $data in cache for an hour so that it can be retrieved next time\n    $cache-\u003eset($key, $data, 3600);\n}\n\n// $data is available here\n```\n\nIn order to delete value you can use:\n\n```php\n$cache-\u003edelete($key);\n// Or all cache\n$cache-\u003eclear();\n```\n\nTo work with values in a more efficient manner, batch operations should be used:\n\n- `getMultiple()`\n- `setMultiple()`\n- `deleteMultiple()`\n\nThis package can be used as a cache handler for the [Yii Caching Library](https://github.com/yiisoft/cache).\n\n## Cleaning up APCu cache\n\nTypically the web processes are separate from CLI so these do not share the same cache instance. Thus, special\nhandling in the web is needed for the case. First, a web-acessible script `apc_clear.php` like the following:\n\n```php\n\u003c?php\nif (in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {\n  apc_clear_cache();\n  apc_clear_cache('user');\n  apc_clear_cache('opcode');\n  echo json_encode(['success' =\u003e true]);\n}\n```\n\nAnd finally, you need some code that calls it:\n\n```php\n$url = 'http://localhost/apc_clear.php';\n$result = json_decode(file_get_contents($url));\n\nif (empty($result['success'])) {\n  echo \"There was an error cleaning up APCu cache.\\n\".\n}\n```\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for\nthat. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Cache Library - APCu Handler is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fcache-apcu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fcache-apcu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fcache-apcu/lists"}