{"id":15679779,"url":"https://github.com/bnomei/kirby3-php-cachedriver","last_synced_at":"2025-05-07T10:24:43.067Z","repository":{"id":45846392,"uuid":"426681081","full_name":"bnomei/kirby3-php-cachedriver","owner":"bnomei","description":"PHP based Cache-Driver","archived":false,"fork":false,"pushed_at":"2024-11-30T15:52:58.000Z","size":111,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-27T18:39:55.560Z","etag":null,"topics":["apcu","cache","include","key","key-value","kirby","kirby-cms","kirby-plugin","kirby3","kirby4","kirby5","opcache","performance","php","value"],"latest_commit_sha":null,"homepage":"https://forum.getkirby.com/t/php-cache-driver-it-is-very-fast/23932","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/bnomei.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"bnomei","patreon":"bnomei","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://buymeacoff.ee/bnomei","https://paypal.me/bnomei"]}},"created_at":"2021-11-10T15:44:54.000Z","updated_at":"2025-01-13T13:10:48.000Z","dependencies_parsed_at":"2025-04-20T15:15:16.069Z","dependency_job_id":null,"html_url":"https://github.com/bnomei/kirby3-php-cachedriver","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-php-cachedriver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-php-cachedriver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-php-cachedriver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-php-cachedriver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnomei","download_url":"https://codeload.github.com/bnomei/kirby3-php-cachedriver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252857493,"owners_count":21815035,"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":["apcu","cache","include","key","key-value","kirby","kirby-cms","kirby-plugin","kirby3","kirby4","kirby5","opcache","performance","php","value"],"created_at":"2024-10-03T16:36:17.195Z","updated_at":"2025-05-07T10:24:42.999Z","avatar_url":"https://github.com/bnomei.png","language":"PHP","funding_links":["https://github.com/sponsors/bnomei","https://patreon.com/bnomei","https://buymeacoff.ee/bnomei","https://paypal.me/bnomei","https://www.buymeacoffee.com/bnomei"],"categories":[],"sub_categories":[],"readme":"# 🐘 Kirby PHP Cache-Driver\n\n![Release](https://flat.badgen.net/packagist/v/bnomei/kirby3-php-cachedriver?color=ae81ff\u0026icon=github\u0026label)\n[![Discord](https://flat.badgen.net/badge/discord/bnomei?color=7289da\u0026icon=discord\u0026label)](https://discordapp.com/users/bnomei)\n[![Buymecoffee](https://flat.badgen.net/badge/icon/donate?icon=buymeacoffee\u0026color=FF813F\u0026label)](https://www.buymeacoffee.com/bnomei)\n\nElephant - a highly performant PHP Cache Driver for Kirby\n\n## Installation\n\n- unzip [master.zip](https://github.com/bnomei/kirby3-php-cachedriver/archive/master.zip) as folder `site/plugins/kirby3-php-cachedriver` or\n- `git submodule add https://github.com/bnomei/kirby3-php-cachedriver.git site/plugins/kirby3-php-cachedriver` or\n- `composer require bnomei/kirby3-php-cachedriver`\n\n## Usage \n\n### Cache methods\n\n```php\n$cache = \\Bnomei\\PHPCache::singleton(); // or\n$cache = elephant();\n\n$cache-\u003eset('key', 'value', $expireInMinutes);\n$value = elephant()-\u003eget('key', $default);\n\nelephant()-\u003eremove('key');\nelephant()-\u003eflush();\n```\n\n### Cache file(s)\n\nAll data is written at the end of the PHP script life-cycle. This does not count against your script execution time, but for example, when you change the value in the cache with each request, writing that big file every time time might prove inefficient. Furthermore, more incremental updates will be written during script execution depending on the `mono_dump` setting. Additions to the cache will also be written in temporary files to improve the stability of the cache.\n\n### Serialization of data\n\nThis plugin defaults to a simple serialization logic, which is quick but only serializes primitive data types, closures, and objects that have a `toArray()`-method like `Kirby\\Cms\\Field` and `Kirby\\Toolkit\\Obj`. This should be enough for most use-cases.\nIf you need broader support set `bnomei.php-cachedriver.serialize` to `json` which will en- and decode your data as JSON before storing it. That is a bit slower but will ensure your data contains only primitive types without the hassle of serializing it manually before caching it.\n\n### OPCache\n\nMake sure [OPCache is configured](https://www.php.net/manual/en/opcache.configuration.php) to load the PHP files from the cache without any delay. Most probably you will have to set these values in your `user.ini` or something similar! If you do not set these values, you might have outdated data being loaded from php files cached by OPCache instead of loading the right ones you want from disk.\n\n```shell\nopcache.enable=1\nopcache.enable_cli=0 # default is 0, leave it like that\nopcache.validate_timestamps=1\nopcache.revalidate_freq=0 # default is 2, 0 =\u003e on every request\n```\n\n\u003e Thanks, Al, for helping me get these config values right.\n\n### Benchmark\n\n```php\nelephant()-\u003ebenchmark(1000);\n```\n\n```shell script\nphp : 0.03383207321167  \nfile : 2.3811981678009\n```\n\n\u003e ATTENTION: This will create and remove a lot of cache files and php-cache files\n\n### No cache when debugging\n\nWhen Kirbys global debug config is set to `true` the complete plugin cache will be flushed and no caches will be read. But entries will be created.\n\n### How to use Elephant with Lapse or Boost\n\nYou need to set the cache driver for the [lapse plugin](https://github.com/bnomei/kirby3-lapse) to `php`. Please be aware that the *mono*-mode is not suited for concurrent writes.\n\n**site/config/config.php**\n```php\n\u003c?php\nreturn [\n    'bnomei.lapse.cache' =\u003e ['type' =\u003e 'php'],\n    'bnomei.boost.cache' =\u003e ['type' =\u003e 'php'],\n    //... other options\n];\n```\n\n### Setup Content-File Cache\n\nUse [Kirby 3 Boost](https://github.com/bnomei/kirby3-boost) to set up a cache for content files.\n\n\n## Settings\n\n| bnomei.php-cachedriver. | Default       | Description                                  |            \n|-------------------------|---------------|----------------------------------------------|\n| mono_dump               | `2048`         | write to cache file every n changes          |\n| check_opcache           | `true`        | check OPCache settings                       |\n| serialize               | `'primitive'` | which is fastest or `'json'` for less hassle |\n\n## Disclaimer\n\nThis plugin is provided \"as is\" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-php-cachedriver/issues/new).\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nIt is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-php-cachedriver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnomei%2Fkirby3-php-cachedriver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-php-cachedriver/lists"}