2017 © Pedro Peláez
 

library laravel-phpredis

Use phpredis as the redis connection in Laravel

image

vetruvet/laravel-phpredis

Use phpredis as the redis connection in Laravel

  • Wednesday, August 17, 2016
  • by vetruvet
  • Repository
  • 5 Watchers
  • 36 Stars
  • 19,396 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 7 Open issues
  • 4 Versions
  • 14 % Grown

The README.md

PhpRedis Connector for Laravel

Laravel by default uses Predis to connect to Redis., (*1)

On servers which have PhpRedis installed, you may want to use it instead of Predis for performance. This package provides a drop-in replacement for the RedisServiceProvider that comes with Laravel., (*2)

Requirements

Installation

First, of course, make sure PhpRedis is installed on the server. See [here][1] for installation instructions., (*3)

Add the dependency to composer.json:, (*4)

"require": {
    "vetruvet/laravel-phpredis": "1.*"
}

Add the PhpRedisServiceProvider to config/app.php (comment out built-in RedisServiceProvider):, (*5)

...
'providers' => array(
    ...
    // 'Illuminate\Redis\RedisServiceProvider',
    'Vetruvet\PhpRedis\PhpRedisServiceProvider',
    ...
),
...

The default Facade alias conflicts with the Redis class provided by PhpRedis. To fix this, rename the alias in config/app.php:, (*6)

...
'aliases' => array(
    ...
    'LRedis'           => 'Illuminate\Support\Facades\Redis', 
    ...
),
...

An unfortunate side effect is that you need to call the Redis functions like LRedis::connection() now which does not look as nice or slick, but everything still works the same way (you can call Redis commands as usual, e.g. LRedis::get('key')., (*7)

Finally run composer update to update and install everything., (*8)

Options

Configuration is just like the default config for Redis in Laravel. In fact, you can switch between PhpRedis and Predis without changing your configuration (no guarantees for clustering or serialization though)., (*9)

All options are optional, you can specify an empty array to get the default connection configuration:, (*10)

'redis' => array(

    'cluster' => true, // if true a RedisArray will be created

    'default' => array(
        'host'       => '127.0.0.1', // default: '127.0.0.1'
        'port'       => 6379,        // default: 6379
        'password'   => password     // default: null
        'prefix'     => 'myapp:',    // default: ''
        'database'   => 7,           // default: 0
        'timeout'    => 0.5,         // default: 0 (no timeout)
        'serializer' => 'igbinary'   // default: 'none', possible values: 'none', 'php', 'igbinary'
    ),

),

The only option that is not self-explanatory is the serializer option. The values correspond directly to the Redis::SERIALIZER_* constants in PhpRedis. If you specify igbinary, igbinary will be used as the serializer if PhpRedis was compiled with --enable-redis-igbinary, falling back to PHP's built-in serializer otherwise., (*11)

The Versions

17/08 2016

dev-master

9999999-dev

Use phpredis as the redis connection in Laravel

  Sources   Download

Apache

The Requires

 

by Valera Trubachev

laravel redis phpredis

09/06 2016

v1.0.4

1.0.4.0

Use phpredis as the redis connection in Laravel

  Sources   Download

Apache

The Requires

 

by Valera Trubachev

laravel redis phpredis

25/01 2016

v1.0.3

1.0.3.0

Use phpredis as the redis connection in Laravel

  Sources   Download

Apache

The Requires

 

by Valera Trubachev

laravel redis phpredis

29/04 2014

1.0.0

1.0.0.0

Use phpredis as the redis connection in Laravel

  Sources   Download

Apache

by Valera Trubachev

laravel redis phpredis