{"id":23359764,"url":"https://github.com/firehed/php-redis-psr16","last_synced_at":"2025-04-07T20:46:03.935Z","repository":{"id":46345094,"uuid":"373229505","full_name":"Firehed/php-redis-psr16","owner":"Firehed","description":null,"archived":false,"fork":false,"pushed_at":"2023-09-14T19:25:32.000Z","size":43,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T08:16:46.207Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Firehed.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}},"created_at":"2021-06-02T16:09:19.000Z","updated_at":"2021-10-20T23:43:16.000Z","dependencies_parsed_at":"2022-09-18T10:42:18.294Z","dependency_job_id":null,"html_url":"https://github.com/Firehed/php-redis-psr16","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fphp-redis-psr16","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fphp-redis-psr16/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fphp-redis-psr16/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Firehed%2Fphp-redis-psr16/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Firehed","download_url":"https://codeload.github.com/Firehed/php-redis-psr16/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247729465,"owners_count":20986392,"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":[],"created_at":"2024-12-21T11:11:54.599Z","updated_at":"2025-04-07T20:46:03.524Z","avatar_url":"https://github.com/Firehed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSR-16 Redis\n\nThis is a Redis implementation for the [PSR-16](https://www.php-fig.org/psr/psr-16/) SimpleCache interface.\n\nThis library actually uses the multi-key operators supported by Redis (`mget`, etc), unlike most other implementations at the time of writing.\n\n## Installation and Usage\n\nInstall: `composer require firehed/redis-psr16`\n\nUsage:\n\n```php\n$redis = new \\Redis();\n$redis-\u003econnect('yourhost', 6379);\n$redis-\u003eauth(['user' =\u003e 'youruser', 'pass' =\u003e 'yourpass']);\n\n$cache = new \\Firehed\\Cache\\RedisPsr16($redis);\n// Use like any other PSR-16 implementation\n```\n\nIf `Redis::OPT_SERIALIZER` is not set (or uses the default `Redis::SERIALIZER_NONE`), this library will automatically set it to `Redis::SERIALIZER_PHP`.\nThis will ensure that non-string values are stored and retreived correctly.\nBe aware that this means if any `object`s are cached, any magic methods related to serialization (`__sleep()`, `__wakeup()`, `__serialize()`, `__unserialize()`) will be called during caching operations.\nSetting that option to any other value before providing Redis to this library will use the set serializer:\n\n```php\nuse Firehed\\Cache\\RedisPsr16;\nuse Redis;\n\n// Automatically sets SERIALIZER_PHP:\n$redis = new Redis();\n// connect/auth\n$cache = new RedisPsr16($redis);\n\n// Uses specified SERIALIZER_JSON\n$redis = new Redis();\n// connect/auth\n$redis-\u003esetOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON);\n$cache = new RedisPsr16($redis);\n```\n\n### Configuration\n\nA runtime mode can be set via the `$mode` constructor parameter:\n\n```php\nuse Firehed\\Cache\\RedisPsr16;\n\n$cache = new RedisPsr16($redis, RedisPsr16::MODE_THROW);\n```\n\n- `RedisPsr16::MODE_THROW` may throw exceptions on network issues (in the same way directly using the `Redis` extension can).\n  Exceptions thrown will implement `Psr\\SimpleCache\\CacheException`, per PSR-16 requirements.\n  This will help expose networking issues and may be beneficial for logging and error handling, but does require calling libraries to handle them.\n  _This is the default mode._\n\n- `RedisPsr16::MODE_FAIL` will prevent exceptions from being thrown.\n  Any error, including networking errors (where the `Redis` extension throws) will be treated as a failure.\n  This could result in misleading behavior around cache misses; if it's important for your application to know the difference between \"miss\" and \"Redis unavailable\", do not use this mode.\n\nThe mode can be adjusted at runtime with `RedisPsr16::setMode($mode)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fphp-redis-psr16","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirehed%2Fphp-redis-psr16","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirehed%2Fphp-redis-psr16/lists"}