Friday, March 13, 2015

Redis in Laravel

Redis in Laravel:

Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, and sorted sets.

Configuration:

The Redis configuration for your application is stored in the app/config/database.php file. Within this file, you will see a redis array containing the Redis servers used by your application:

'redis' => array(

    'cluster' => true,

    'default' => array('host' => '127.0.0.1', 'port' => 6379),

),

Usage:

$redis = Redis::connection();
$redis = Redis::connection('other');
$redis->set('name', 'Taylor');

$name = $redis->get('name');

$values = $redis->lrange('names', 5, 10);
$values = $redis->command('lrange', array(5, 10));
Redis::set('name', 'Taylor');

$name = Redis::get('name');

$values = Redis::lrange('names', 5, 10);    

Thanks

No comments:

Post a Comment