2017 © Pedro Peláez
 

library laravel-ps-redis

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

image

itryit/laravel-ps-redis

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  • Friday, December 25, 2015
  • by iTryIt
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5,318 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 5 Versions
  • 8 % Grown

The README.md

Laravel-PSRedis

A simple sentinel/redis driver wrapper for laravel., (*1)

The default laravel redis driver supports redis clusters, however, it does not support high availability with redis, which is where Laravel-PSRedis comes to the rescue., (*2)

With Laravel-PSRedis you'll get all the laravel redis magic that you aleady have such as Redis::set() and Redis::get(), and even session, queue, and cache support using redis, you'll just be able to leverage High Avaliability redis instances instead of a simple cluster., (*3)

We do this by asking your Redis Sentinels the location of your master before creating our Redis bindings in the IOC Container. By doing this we ensure anytime your app has a connection to your redis instance, that connection is to master., (*4)

README Contents

, (*5)

Installation

, (*6)

Installation for Laravel 5

You can install Laravel-PSRedis easily with composer., (*7)

    "require": {  
        "itryit/laravel-ps-redis": "v2.2",
    },

, (*8)

Configuration

Next, just fill in your sentinel/redis server info in the app/config/database.php config files that already exist in your application., (*9)

You may already have some default laravel config values in place in your database config file that looks like this., (*10)

/*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */
    'redis' => [
        'cluster' => false,
        'default' => [
            'host'     => '127.0.0.1',
            'port'     => 6379,
            'database' => 0,
        ],
    ],

Just overwrite those with the values below and fill in your server info., (*11)

    /** redisConfigName config is supported since version 2.2 */
    'redisConfigName' => 'redis', // your redis setting key name, 'redis' for default, this would be compatible with past versions

    'redis' => [

        /** the name of the redis node set */
        'nodeSetName' => 'your-sentinel-node-set-name',

        'cluster' => false,

        /** database config is supported since version 2.1 */
        'database' => 0, // redis database choice

        /** Array of sentinels */
        'masters' => [
            [
                'host' => 'sentinel-instance.domain.com',
                'port' => '26379',
            ],
            [
                'host' => 'sentinel-instance.domain.com',
                'port' => '26379',
            ]
        ],

        /** how long to wait and try again if we fail to connect to master */
        'backoff-strategy' => [
            'max-attempts' => 10, // the maximum-number of attempt possible to find master
            'wait-time' => 500,   // miliseconds to wait for the next attempt
            'increment' => 1.5, // multiplier used to increment the back off time on each try
        ]
    ];  

, (*12)

The Service Provider

Finally, you just need to add the service provider to the providers array in app.php and comment or remove the redis service provider., (*13)

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    */
    'providers' => [
        ...
        // 'Illuminate\Redis\RedisServiceProvider', # comment this out
        'Itryit\LaravelPSRedisHelper\LaravelPSRedisServiceProvider' # add this
    ],

Note: you may have to composer dump-autoload after adding the service provider, (*14)

, (*15)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

, (*16)

Testing

Feel free to clone the repo and run the unit tests locally., (*17)

    ./vendor/bin/phpunit -c ./phpunit.xml 

, (*18)

License

The MIT License (MIT), (*19)

The Versions

25/12 2015

dev-master

9999999-dev

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Russell(origin), iTryIt

25/12 2015

dev-develop

dev-develop

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Russell(origin), iTryIt

25/12 2015

v2.2

2.2.0.0

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Russell(origin), iTryIt

25/12 2015

v2.1

2.1.0.0

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Russell(origin), iTryIt

10/11 2015

v2.0

2.0.0.0

A simple sentinel/redis driver wrapper for laravel 5.*. Rewrited For jamescauwelier/psredis

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Russell(origin), iTryIt