PHPackages                             dynamonet/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. [Caching](/categories/caching)
4. /
5. dynamonet/redis

ActiveLibrary[Caching](/categories/caching)

dynamonet/redis
===============

Redis extension wrapper, with nice Lua-scripting support, and other helpful utilities

v1.3.2(3y ago)12.0k1MITPHPPHP ^7.1CI failing

Since Mar 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dynamonet/php-redis)[ Packagist](https://packagist.org/packages/dynamonet/redis)[ RSS](/packages/dynamonet-redis/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (16)Used By (1)

php-redis
=========

[](#php-redis)

A wrapper for the [phpredis](https://github.com/phpredis/phpredis) extension, with nice pipelining interfaces, Lua-scripting support, and other helpful utilities.

Install
-------

[](#install)

```
composer install dynamonet/redis

```

Initialization
--------------

[](#initialization)

```
use Dynamo\Redis\Client as RedisClient;

$redis = new RedisClient([
    'host' => 'localhost',
    'port' => 6379,
    //'timeout' => xxx,
    //'retry_interval' => xxx, //
]);

// you can now start sending commands, without the need for an explicit "connect" call
$redis->set('mykey', 'value');
```

Pipelining
----------

[](#pipelining)

```
$result = $redis->pipeline()
    ->set('key1', 'value1')
    ->incr('key2')
    ->get('key2')
    ->exec();

var_dump($result); // an array with the result for every queued command
```

Redis 7 Functions
-----------------

[](#redis-7-functions)

Redis 7 introduced the concept of "functions", which are named scripts, tipically written in Lua, which you invoke by the name you choose, like so:

```
FCALL myHelloFunction 1 "John Snow"
```

Prior to Redis functions, the only way to invoke a custom script was using the SHA1 string returned by the `LOAD SCRIPT` command 🤮

This library already has support for Redis 7 functions. All you have to do is register your functions, and then invoke them as if they were existing commands on the client.

```
// Register my custom functions
$redis->loadFunctionScript($path_to_my_functions_script, [
    'functionA' => 1,
    'functionB' => 2,
    'functionC' => 0,
]);
```

Notice that associative array passed as the second argument. That argument is mandatory, and is the only way we have to tell the client which functions are exposed in the script, and how many key (mandatory) arguments have each of our custom functions.

```
// Invoking my functions
$redis->functionA('Hello');
$redis->functionB('World', 2);
$redis->functionA();
```

Lua scripting
-------------

[](#lua-scripting)

Lua scripts in Redis are like traditional database Stored Procedures, but on steroids, because you write them in Lua, so you may use conditionals, loops, and all the flow control structures available in the Lua language. The only downside of Redis scripting (if your are using any version older than 7) is having to use a SHA1 string to invoke your scripts. Fortunately, this library will make your Lua scripting much more pleasant.

Recomended use: have your Lua scripts in separate .lua files, load them to your client, and assign each script an alias:

```
use Dynamo\Redis\LuaScript;

$redis->loadScript(
    LuaScript::fromFile(
        $path_to_my_lua_script,
        2, // amount of mandatory arguments
        'myluacmd' //alias for the script
    ),
    true //register the script NOW. If "false" is provided, it will be lazy-loaded
);

//now, you can call your Lua command as if it were a regular Redis command
$redis->myluacmd('blablabla', 2);

//you can also call your custom commands in a pipeline
$result = $redis->pipeline()
    ->set('key1', 'value1')
    ->incr('key2')
    ->get('key2')
    ->myluacmd('blablabla', 2)
    ->exec();
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~65 days

Recently: every ~33 days

Total

15

Last Release

1329d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/095a5072227e4e88bfc7412863d77d0f5d65b8653e6b249de29bab51eb27067c?d=identicon)[dynamonet](/maintainers/dynamonet)

---

Top Contributors

[![dynamonet](https://avatars.githubusercontent.com/u/44091316?v=4)](https://github.com/dynamonet "dynamonet (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

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