{"id":14966345,"url":"https://github.com/yiisoft/cache-memcached","last_synced_at":"2026-03-05T22:06:41.457Z","repository":{"id":35063347,"uuid":"184578512","full_name":"yiisoft/cache-memcached","owner":"yiisoft","description":"Yii Cache Library - Memcached Handler","archived":false,"fork":false,"pushed_at":"2024-12-13T09:39:09.000Z","size":126,"stargazers_count":13,"open_issues_count":2,"forks_count":5,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-10-22T15:56:39.522Z","etag":null,"topics":["cache","cache-storage","hacktoberfest","memcached","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"]}},"created_at":"2019-05-02T12:39:15.000Z","updated_at":"2025-01-06T11:40:51.000Z","dependencies_parsed_at":"2022-08-25T00:50:50.667Z","dependency_job_id":"b0db8ce2-4445-469d-905e-c04b190bd9e3","html_url":"https://github.com/yiisoft/cache-memcached","commit_stats":{"total_commits":92,"total_committers":15,"mean_commits":6.133333333333334,"dds":0.6195652173913043,"last_synced_commit":"311396a9c316e9759379c5524076dcd0a4eecfb0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/yiisoft/cache-memcached","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-memcached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-memcached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-memcached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-memcached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/cache-memcached/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fcache-memcached/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30152073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T21:15:50.531Z","status":"ssl_error","status_checked_at":"2026-03-05T21:15:11.173Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cache","cache-storage","hacktoberfest","memcached","psr-16","yii3"],"created_at":"2024-09-24T13:36:15.052Z","updated_at":"2026-03-05T22:06:41.241Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/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 - Memcached Handler\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/cache-memcached/v/stable.png)](https://packagist.org/packages/yiisoft/cache-memcached)\n[![Total Downloads](https://poser.pugx.org/yiisoft/cache-memcached/downloads.png)](https://packagist.org/packages/yiisoft/cache-memcached)\n[![Build status](https://github.com/yiisoft/cache-memcached/workflows/build/badge.svg)](https://github.com/yiisoft/cache-memcached/actions?query=workflow%3Abuild)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/cache-memcached/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/cache-memcached/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/cache-memcached/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/cache-memcached/?branch=master)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fcache-memcached%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/cache-memcached/master)\n[![static analysis](https://github.com/yiisoft/cache-memcached/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/cache-memcached/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/cache-memcached/coverage.svg)](https://shepherd.dev/github/yiisoft/cache-memcached)\n\nThis package provides the [Memcached](https://www.php.net/manual/book.memcached.php)\nhandler 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 in\na distributed applications (e.g. with several servers, load balancers, etc.).\n\n## Requirements\n\n- PHP 8.0 or higher.\n- `Memcached` PHP extension.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/cache-memcached\n```\n\n## Configuration\n\nCreating an instance:\n\n```php\n$cache = new \\Yiisoft\\Cache\\Memcached\\Memcached($persistentId, $servers);\n```\n\n`$persistentId (string)` - The ID that identifies the Memcached instance is an empty string by default.\nBy default, the Memcached instances are destroyed at the end of the request.\nTo create an instance that persists between requests, use persistent_id to specify a unique ID for the instance.\nAll instances created with the same `$persistentId` will share the same connection.\n\nFor more information, see the description of the\n[`\\Memcached::__construct()`](https://www.php.net/manual/memcached.construct.php).\n\n`$servers (array)` - List of memcached servers that will be added to the server pool.\n\nList has the following structure:\n\n```php\n$servers =\u003e [\n    [\n        'host' =\u003e 'server-1',\n        'port' =\u003e 11211,\n        'weight' =\u003e 100,\n    ],\n    [\n        'host' =\u003e 'server-2',\n        'port' =\u003e 11211,\n        'weight' =\u003e 50,\n    ],\n];\n```\n\nThe default value:\n\n```php\n$servers =\u003e [\n    [\n        'host' =\u003e Memcached::DEFAULT_SERVER_HOST, // '127.0.0.1'\n        'port' =\u003e Memcached::DEFAULT_SERVER_PORT, // 11211\n        'weight' =\u003e Memcached::DEFAULT_SERVER_WEIGHT, // 1\n    ],\n];\n```\n\nFor more information, see the description of the\n[`\\Memcached::addServers()`](https://www.php.net/manual/memcached.addservers.php).\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\\Memcached\\Memcached();\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## 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 - Memcached 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-memcached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fcache-memcached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fcache-memcached/lists"}