{"id":19458857,"url":"https://github.com/leafsphp/redis","last_synced_at":"2025-02-25T11:43:10.749Z","repository":{"id":57013263,"uuid":"372234153","full_name":"leafsphp/redis","owner":"leafsphp","description":"Redis helper for your PHP apps","archived":false,"fork":false,"pushed_at":"2023-09-03T22:10:40.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T09:58:50.396Z","etag":null,"topics":["leafphp","php","redis"],"latest_commit_sha":null,"homepage":"https://leafphp.dev/modules/redis/","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/leafsphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"leaf","github":"leafsphp"}},"created_at":"2021-05-30T14:21:19.000Z","updated_at":"2021-12-16T09:04:40.000Z","dependencies_parsed_at":"2022-08-21T13:40:55.372Z","dependency_job_id":"4d7812fa-05d8-47cb-b912-bece6770fe4b","html_url":"https://github.com/leafsphp/redis","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"6797515d2392d00b31dad56a9c136f7495dc3770"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fredis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fredis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fredis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafsphp%2Fredis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafsphp","download_url":"https://codeload.github.com/leafsphp/redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240436549,"owners_count":19800938,"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":["leafphp","php","redis"],"created_at":"2024-11-10T17:28:46.028Z","updated_at":"2025-02-25T11:43:10.709Z","avatar_url":"https://github.com/leafsphp.png","language":"PHP","readme":"\u003c!-- markdownlint-disable no-inline-html --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg src=\"https://leafphp.dev/logo-circle.png\" height=\"100\"/\u003e\n  \u003cbr\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eLeaf Redis\u003c/h1\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/leafs/redis/v/stable)](https://packagist.org/packages/leafs/redis)\n[![Total Downloads](https://poser.pugx.org/leafs/redis/downloads)](https://packagist.org/packages/leafs/redis)\n[![License](https://poser.pugx.org/leafs/redis/license)](https://packagist.org/packages/leafs/redis)\n\nLeaf Redis provides a simple interface for interacting with Redis using PHP. It also comes with a bunch of CLI commands for Leaf based frameworks.\n\n## Installation\n\n*To get started, be sure to have redis installed on your machine.*\n\nYou can quickly and simply install Leaf Redis with the Leaf CLI:\n\n```bash\nleaf install redis\n```\n\nOr with composer:\n\n```bash\ncomposer require leafs/redis\n```\n\n## Getting Started\n\nTo get started with Leaf Redis, you simply need to call the `init` method and pass in any configuration you need.\n\n```php\nLeaf\\Redis::init();\n```\n\nThis will initialize a new redis connection, from there, you can call any function you need to call.\n\n### Aloe CLI\n\nAlthough Leaf Redis can be used outside the Leaf environment, there's more support for Leaf based frameworks. Leaf Redis comes with out of the box support for Aloe CLI which is used in Leaf MVC and Leaf API. To get started, head over to the `leaf` file in the root directory of your Leaf API/Leaf MVC app or wherever aloe CLI is registered and register a new command.\n\n```php\n$console-\u003eregister(\\Leaf\\Redis::commands());\n```\n\nFrom there you should have access to a bunch of new commands from Leaf redis. The available commands are:\n\n```sh\nredis\n  redis:install  Create leaf redis config and .env variables\n  redis:server   Start redis server\n```\n\n## Config\n\nAs mentioned above, the `init` method takes in an array for configuration. Below is the default config for `init`.\n\n```php\n/*\n|--------------------------------------------------------------------------\n| Redis host\n|--------------------------------------------------------------------------\n|\n| Set the host for redis connection\n|\n*/\n'host' =\u003e '127.0.0.1',\n\n/*\n|--------------------------------------------------------------------------\n| Redis host port\n|--------------------------------------------------------------------------\n|\n| Set the port for redis host\n|\n*/\n'port' =\u003e 6379,\n\n/*\n|--------------------------------------------------------------------------\n| Redis auth\n|--------------------------------------------------------------------------\n|\n| Set the password for redis connection\n|\n*/\n'password' =\u003e null,\n\n/*\n|--------------------------------------------------------------------------\n| Redis session handler\n|--------------------------------------------------------------------------\n|\n| Set redis as session save handler\n|\n*/\n'session' =\u003e false,\n\n/*\n|--------------------------------------------------------------------------\n| Redis connection timeout\n|--------------------------------------------------------------------------\n|\n| Value in seconds (optional, default is 0.0 meaning unlimited)\n|\n*/\n'connection.timeout' =\u003e 0.0,\n\n/*\n|--------------------------------------------------------------------------\n| Redis connection reserved\n|--------------------------------------------------------------------------\n|\n| should be null if $retryInterval is specified\n|\n*/\n'connection.reserved' =\u003e null,\n\n/*\n|--------------------------------------------------------------------------\n| Redis session handler\n|--------------------------------------------------------------------------\n|\n| Connection retry interval in milliseconds.\n|\n*/\n'connection.retryInterval' =\u003e 0,\n\n/*\n|--------------------------------------------------------------------------\n| Redis connection read timeout\n|--------------------------------------------------------------------------\n|\n| Value in seconds (optional, default is 0 meaning unlimited\n|\n*/\n'connection.readTimeout' =\u003e 0.0,\n\n/*\n|--------------------------------------------------------------------------\n| Redis session save_path\n|--------------------------------------------------------------------------\n|\n| Save path for redis session. Leave null to automatically\n| generate the session save path. You can also use multiple save urls\n| by passing in an array.\n|\n*/\n'session.savePath' =\u003e null,\n\n/*\n|--------------------------------------------------------------------------\n| Redis session save_path options\n|--------------------------------------------------------------------------\n|\n| Options for session save path. You can pass in multiple options in\n| the order of the save path above.\n|\n*/\n'session.saveOptions' =\u003e [],\n```\n\n```php\nuse Leaf\\Redis;\n\nRedis::init([\n  // you can use multiple hosts\n  'session.savePath' =\u003e ['tcp://host1:6379', 'tcp://host2:6379'],\n\n  // the first array is for the first host, second for the second host\n  'session.saveOptions' =\u003e [['weight' =\u003e 1], ['weight' =\u003e 2]],\n]);\n```\n\n## Available Methods\n\n### set\n\nThis allows you to set a redis entry.\n\n```php\nLeaf\\Redis::set('key', 'value');\n\n// you can also use arrays to set multiple values at once\n\nLeaf\\Redis::set(['key' =\u003e 'value', 'key2' =\u003e 'value']);\n```\n\n### get\n\nThis returns a saved redis entry.\n\n```php\n$value = Leaf\\Redis::get('key');\n\n// You can also get multiple entries at once\n\n$data = Leaf\\Redis::get(['key', 'key2']);\n\n// $data =\u003e [key =\u003e value, key2 =\u003e value]\n```\n\n### ping\n\nPing the redis server\n\n```php\nLeaf\\Redis::ping();\n```\n\n## 💬 Stay In Touch\n\n-   [Twitter](https://twitter.com/leafphp)\n-   [Join the forum](https://github.com/leafsphp/leaf/discussions/37)\n-   [Chat on discord](https://discord.com/invite/Pkrm9NJPE3)\n\n## 📓 Learning Leaf 3\n\n-   Leaf has a very easy to understand [documentation](https://leafphp.dev) which contains information on all operations in Leaf.\n-   You can also check out our [youtube channel](https://www.youtube.com/channel/UCllE-GsYy10RkxBUK0HIffw) which has video tutorials on different topics\n-   You can also learn from [codelabs](https://codelabs.leafphp.dev) and contribute as well.\n\n## 😇 Contributing\n\nWe are glad to have you. All contributions are welcome! To get started, familiarize yourself with our [contribution guide](https://leafphp.dev/community/contributing.html) and you'll be ready to make your first pull request 🚀.\n\nTo report a security vulnerability, you can reach out to [@mychidarko](https://twitter.com/mychidarko) or [@leafphp](https://twitter.com/leafphp) on twitter. We will coordinate the fix and eventually commit the solution in this project.\n\n## 🤩 Sponsoring Leaf\n\nYour cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on [open collective](https://opencollective.com/leaf) or check the [contribution page](https://leafphp.dev/support/) for a list of ways to contribute.\n\nAnd to all our [existing cash/code contributors](https://leafphp.dev#sponsors), we love you all ❤️\n","funding_links":["https://opencollective.com/leaf","https://github.com/sponsors/leafsphp"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Fredis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleafsphp%2Fredis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleafsphp%2Fredis/lists"}