{"id":13549064,"url":"https://github.com/felixarntz/wp-psr-cache","last_synced_at":"2025-08-12T16:09:19.815Z","repository":{"id":62504117,"uuid":"118650573","full_name":"felixarntz/wp-psr-cache","owner":"felixarntz","description":"Object cache implementation for WordPress that acts as an adapter for PSR-6 and PSR-16 caching libraries.","archived":false,"fork":false,"pushed_at":"2018-04-02T10:30:55.000Z","size":112,"stargazers_count":34,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-02T20:52:18.470Z","etag":null,"topics":["object-cache","psr-16","psr-6","wordpress-dropin","wordpress-muplugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felixarntz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-23T18:20:20.000Z","updated_at":"2025-06-14T10:02:56.000Z","dependencies_parsed_at":"2022-11-02T12:30:29.971Z","dependency_job_id":null,"html_url":"https://github.com/felixarntz/wp-psr-cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/felixarntz/wp-psr-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixarntz%2Fwp-psr-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixarntz%2Fwp-psr-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixarntz%2Fwp-psr-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixarntz%2Fwp-psr-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixarntz","download_url":"https://codeload.github.com/felixarntz/wp-psr-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixarntz%2Fwp-psr-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270092414,"owners_count":24525394,"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-12T02:00:09.011Z","response_time":80,"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":["object-cache","psr-16","psr-6","wordpress-dropin","wordpress-muplugin"],"created_at":"2024-08-01T12:01:17.815Z","updated_at":"2025-08-12T16:09:19.777Z","avatar_url":"https://github.com/felixarntz.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"[![Build Status](https://api.travis-ci.org/felixarntz/wp-psr-cache.png?branch=master)](https://travis-ci.org/felixarntz/wp-psr-cache)\n[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)\n[![Code Climate](https://codeclimate.com/github/felixarntz/wp-psr-cache/badges/gpa.svg)](https://codeclimate.com/github/felixarntz/wp-psr-cache)\n[![Test Coverage](https://codeclimate.com/github/felixarntz/wp-psr-cache/badges/coverage.svg)](https://codeclimate.com/github/felixarntz/wp-psr-cache/coverage)\n[![Latest Stable Version](https://poser.pugx.org/felixarntz/wp-psr-cache/version)](https://packagist.org/packages/felixarntz/wp-psr-cache)\n[![License](https://poser.pugx.org/felixarntz/wp-psr-cache/license)](https://packagist.org/packages/felixarntz/wp-psr-cache)\n\n# WP PSR Cache\n\nObject cache implementation for WordPress that acts as an adapter for PSR-6 and PSR-16 caching libraries.\n\n## What do PSR-6 and PSR-16 mean?\n\n[PSR-6](http://www.php-fig.org/psr/psr-6/) and [PSR-16](http://www.php-fig.org/psr/psr-16/) are standards established by the [PHP-FIG](http://www.php-fig.org/) organization. These standards are commonly used in PHP projects of any kind (WordPress is unfortunately an exception), and since this library acts as an adapter, you can use any compatible caching library of your choice with WordPress now. Popular examples include the [Symfony Cache Component](https://github.com/symfony/cache) or [Stash](https://github.com/tedious/Stash).\n\n## Features\n\n* Any PSR-6 or PSR-16 cache implementation can be used\n* Persistent and non-persistent cache implementations can be individually specified\n* Support for reading/writing/deleting multiple cache keys at once\n* Only checks persistent cache if value not already present in non-persistent cache\n* Full multisite support, including site and network switching\n* Allows registration of further cache implementations for fine-grained control per cache group\n\n## How to Install\n\nRequire this library as a dependency when managing your project with Composer (for example by using [Bedrock](https://github.com/roots/bedrock)). You also have to install an actual [PSR-6](https://packagist.org/providers/psr/cache-implementation) or [PSR-16](https://packagist.org/providers/psr/simple-cache-implementation) cache implementation.\n\nAfter the installation, you need to move the `includes/object-cache.php` file into your `wp-content` directory. If you prefer, you can also automate that process by adding the following to your project's `composer.json`:\n\n```\n\t\"scripts\": {\n\t\t\"post-install-cmd\": [\n\t\t\t\"cp -rp web/app/mu-plugins/wp-psr-cache/includes/object-cache.php web/app/object-cache.php\"\n\t\t]\n\t}\n```\n\nThen, replace the inline comment in the `object-cache.php` file with the actual instantiations of the classes you want to use. You need to provide two implementations, one for the persistent cache and another for the non-persistent cache.\n\nTo prevent conflicts with multiple WordPress installations accessing the same cache service, it is recommended to define a unique `WP_CACHE_KEY_PREFIX` constant in your `wp-config.php` file.\n\n### Example\n\nThe following example uses the `symfony/cache` library, so you have to require it in your `composer.json`. It then uses that library's Memcached implementation as persistent cache and its array storage as non-persistent cache.\n\n```php\n\u003c?php\n/**\n * Object cache drop-in\n *\n * @package LeavesAndLove\\WpPsrCache\n * @license GNU General Public License, version 2\n * @link    https://github.com/felixarntz/wp-psr-cache\n */\n\nuse LeavesAndLove\\WpPsrCache\\ObjectCacheService;\nuse Symfony\\Component\\Cache\\Simple\\MemcachedCache;\nuse Symfony\\Component\\Cache\\Simple\\ArrayCache;\n\ndefined( 'ABSPATH' ) || exit;\n\nObjectCacheService::loadApi();\n\n/**\n * Defines and thus starts the object cache.\n *\n * @since 1.0.0\n */\nfunction wp_psr_start_cache() {\n\t$memcached = new Memcached();\n\t$memcached-\u003eaddServer( '127.0.0.1', 11211, 20 );\n\n\twp_cache_start( new MemcachedCache( $memcached ), new ArrayCache() );\n}\n\nwp_psr_start_cache();\n\n```\n\nIf you prefer to have more granular control and use more than just one persistent and one non-persistent cache, you can register additional cache adapters using the [`LeavesAndLove\\WpPsrCache\\CacheSelector\\CacheSelector`](https://github.com/felixarntz/wp-psr-cache/blob/master/src/CacheSelector/CacheSelector.php) interface. The implementation used by the object cache can easily be retrieved via `wp_object_cache()-\u003egetSelector()`.\n\n## Requirements\n\n* PHP \u003e= 7.0\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore --\u003e\n| [\u003cimg src=\"https://avatars1.githubusercontent.com/u/3531426?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eFelix Arntz\u003c/b\u003e\u003c/sub\u003e](https://leaves-and-love.net)\u003cbr /\u003e[💻](https://github.com/felixarntz/wp-psr-cache/commits?author=felixarntz \"Code\") [🐛](https://github.com/felixarntz/wp-psr-cache/issues?q=author%3Afelixarntz \"Bug reports\") [📖](https://github.com/felixarntz/wp-psr-cache/commits?author=felixarntz \"Documentation\") [💡](#example-felixarntz \"Examples\") [🤔](#ideas-felixarntz \"Ideas, Planning, \u0026 Feedback\") [⚠️](https://github.com/felixarntz/wp-psr-cache/commits?author=felixarntz \"Tests\") | [\u003cimg src=\"https://avatars1.githubusercontent.com/u/83631?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlain Schlesser\u003c/b\u003e\u003c/sub\u003e](https://www.alainschlesser.com/)\u003cbr /\u003e[💻](https://github.com/felixarntz/wp-psr-cache/commits?author=schlessera \"Code\") [🐛](https://github.com/felixarntz/wp-psr-cache/issues?q=author%3Aschlessera \"Bug reports\") [👀](#review-schlessera \"Reviewed Pull Requests\") | [\u003cimg src=\"https://avatars2.githubusercontent.com/u/6049306?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eThorsten Frommen\u003c/b\u003e\u003c/sub\u003e](https://tfrommen.de)\u003cbr /\u003e[👀](#review-tfrommen \"Reviewed Pull Requests\") | [\u003cimg src=\"https://avatars0.githubusercontent.com/u/2005352?v=4\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eJip\u003c/b\u003e\u003c/sub\u003e](http://www.jipmoors.nl)\u003cbr /\u003e[🤔](#ideas-moorscode \"Ideas, Planning, \u0026 Feedback\") |\n| :---: | :---: | :---: | :---: |\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixarntz%2Fwp-psr-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixarntz%2Fwp-psr-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixarntz%2Fwp-psr-cache/lists"}