PHPackages                             leafs/redis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. leafs/redis

ActiveLibrary[Database &amp; ORM](/categories/database)

leafs/redis
===========

Super simple redis helper for your PHP apps.

v4.1(4mo ago)16221MITPHP

Since May 30Pushed 4mo agoCompare

[ Source](https://github.com/leafsphp/redis)[ Packagist](https://packagist.org/packages/leafs/redis)[ Docs](https://github.com/leafsphp/redis)[ GitHub Sponsors](https://github.com/leafsphp)[ Fund](https://opencollective.com/leaf)[ RSS](/packages/leafs-redis/feed)WikiDiscussions v4.x Synced today

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

 [![](https://camo.githubusercontent.com/136ea9423315228351bc8bb4b237f8e7630afb7b826058fb938de46f6bf932ac/68747470733a2f2f6c6561662d646f63732e6e65746c6966792e6170702f696d616765732f6c6f676f2e706e67)](https://camo.githubusercontent.com/136ea9423315228351bc8bb4b237f8e7630afb7b826058fb938de46f6bf932ac/68747470733a2f2f6c6561662d646f63732e6e65746c6966792e6170702f696d616765732f6c6f676f2e706e67)

Leaf Redis Helper
=================

[](#leaf-redis-helper)

Leaf Redis
==========

[](#leaf-redis)

This is a new addition to Leaf's collection of packages. Unlike other packages, this one doesn't come pre-packaged with Leaf by default and so needs to be installed separately.

Installation
------------

[](#installation)

You can quickly and simply install Leaf Redis through composer.

```
composer require leafs/redis
```

**NOTE:** Leaf redis is a separate package and so can be used outside of Leaf.

Getting Started
---------------

[](#getting-started)

To get started with Leaf Redis, you simply need to call the `init` method and pass in any configuration you need.

```
Leaf\Redis::init();
```

This will initialize a new redis connection, from there, you can call any function you need to call.

### Aloe CLI

[](#aloe-cli)

Although 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.

```
$console->register(\Leaf\Redis::commands());
```

From there you should have access to a bunch of new commands from Leaf redis. The available commands are:

```
redis
  redis:install  Create leaf redis config and .env variables
  redis:server   Start redis server
```

Config
------

[](#config)

As mentioned above, the `init` method takes in an array for configuration. Below is the default config for `init`.

```
/*
|--------------------------------------------------------------------------
| Redis host
|--------------------------------------------------------------------------
|
| Set the host for redis connection
|
*/
"host" => "127.0.0.1",

/*
|--------------------------------------------------------------------------
| Redis host port
|--------------------------------------------------------------------------
|
| Set the port for redis host
|
*/
"port" => 6379,

/*
|--------------------------------------------------------------------------
| Redis auth
|--------------------------------------------------------------------------
|
| Set the password for redis connection
|
*/
"password" => null,

/*
|--------------------------------------------------------------------------
| Redis session handler
|--------------------------------------------------------------------------
|
| Set redis as session save handler
|
*/
"session" => false,

/*
|--------------------------------------------------------------------------
| Redis connection timeout
|--------------------------------------------------------------------------
|
| Value in seconds (optional, default is 0.0 meaning unlimited)
|
*/
"connection.timeout" => 0.0,

/*
|--------------------------------------------------------------------------
| Redis connection reserved
|--------------------------------------------------------------------------
|
| should be null if $retryInterval is specified
|
*/
"connection.reserved" => null,

/*
|--------------------------------------------------------------------------
| Redis session handler
|--------------------------------------------------------------------------
|
| Connection retry interval in milliseconds.
|
*/
"connection.retryInterval" => 0,

/*
|--------------------------------------------------------------------------
| Redis connection read timeout
|--------------------------------------------------------------------------
|
| Value in seconds (optional, default is 0 meaning unlimited
|
*/
"connection.readTimeout" => 0.0,

/*
|--------------------------------------------------------------------------
| Redis session save_path
|--------------------------------------------------------------------------
|
| Save path for redis session. Leave null to automatically
| generate the session save path. You can also use multiple save urls
| by passing in an array.
|
*/
"session.savePath" => null,

/*
|--------------------------------------------------------------------------
| Redis session save_path options
|--------------------------------------------------------------------------
|
| Options for session save path. You can pass in multiple options in
| the order of the save path above.
|
*/
"session.saveOptions" => [],
```

```
use Leaf\Redis;

Redis::init([
  // you can use multiple hosts
  "session.savePath" => ["tcp://host1:6379", "tcp://host2:6379"],

  // the first array is for the first host, second for the second host
  "session.saveOptions" => [["weight" => 1], ["weight" => 2]],
]);
```

Available Methods
-----------------

[](#available-methods)

### set

[](#set)

This allows you to set a redis entry.

```
Leaf\Redis::set("key", "value");

// you can also use arrays to set multiple values at once

Leaf\Redis::set(["key" => "value", "key2" => "value"]);
```

### get

[](#get)

This returns a saved redis entry.

```
$value = Leaf\Redis::get("key");

// You can also get multiple entries at once

$data = Leaf\Redis::get(["key", "key2"]);

// $data => [key => value, key2 => value]
```

### ping

[](#ping)

Ping the redis server

```
Leaf\Redis::ping();
```

💬 Stay In Touch
---------------

[](#-stay-in-touch)

- [Twitter](https://twitter.com/leafphp)
- [Join the forum](https://github.com/leafsphp/leaf/discussions/37)
- [Chat on discord](https://discord.com/invite/Pkrm9NJPE3)

📓 Learning Leaf 3
-----------------

[](#-learning-leaf-3)

- Leaf has a very easy to understand [documentation](https://leafphp.dev) which contains information on all operations in Leaf.
- You can also check out our [youtube channel](https://www.youtube.com/channel/UCllE-GsYy10RkxBUK0HIffw) which has video tutorials on different topics
- We are also working on codelabs which will bring hands-on tutorials you can follow and contribute to.

😇 Contributing
--------------

[](#-contributing)

We 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 🚀.

To 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.

### Code contributors

[](#code-contributors)

   [ ![](https://avatars.githubusercontent.com/u/26604242?v=4)
  **Michael Darko**  ](https://github.com/mychidarko)  🤩 Sponsoring Leaf
-----------------

[](#-sponsoring-leaf)

Your 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.

And to all our existing cash/code contributors, we love you all ❤️

### Cash contributors

[](#cash-contributors)

   [ ![](https://camo.githubusercontent.com/43586d8f5e07014bc26b4f937b4b231520f65723d7cd23c92af58411ae6e8295/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f6161726f6e2d736d697468332f303865653632302f6176617461722f3235362e706e67)
 **Aaron Smith** ](https://opencollective.com/aaron-smith3)   [ ![](https://camo.githubusercontent.com/e98947a206f1d93c9ca8711e566e5c10d529f32ac6063aeecac96cd17ebdb3b5/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f70657465722d626f676e65722f6176617461722f3235362e706e67)
 **Peter Bogner** ](https://opencollective.com/peter-bogner)   [ ![](https://camo.githubusercontent.com/e6a7c11e7c47883f1ec06ab44f4b3cb96046f8fc3d939919bc889a44f7d1e4cd/68747470733a2f2f696d616765732e6f70656e636f6c6c6563746976652e636f6d2f67756573742d33323633346664612f6176617461722e706e67)
 **Vano** ](#)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance76

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~323 days

Recently: every ~197 days

Total

6

Last Release

142d ago

Major Versions

v0.1.1 → v4.02025-02-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29547806?v=4)[Mychi](/maintainers/Mychi)[@mychi](https://github.com/mychi)

---

Top Contributors

[![mychidarko](https://avatars.githubusercontent.com/u/26604242?v=4)](https://github.com/mychidarko "mychidarko (24 commits)")

---

Tags

leafphpphpredisphpdatabaserediscachestorageleaf

### Embed Badge

![Health badge](/badges/leafs-redis/health.svg)

```
[![Health](https://phpackages.com/badges/leafs-redis/health.svg)](https://phpackages.com/packages/leafs-redis)
```

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

590440.9k2](/packages/spiritix-lada-cache)[ymigval/laravel-model-cache

Laravel package for caching Eloquent model queries

7636.6k2](/packages/ymigval-laravel-model-cache)[leafs/cli

A simple command line tool for installing and interacting with your leaf apps

148.8k](/packages/leafs-cli)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
