Laravel - Redis - Interacting With Redis

You may interact with Redis by calling various methods on the Redis facade. The Redis facade supports dynamic methods, meaning you may call any Redis command on the facade and the command will be passed directly to Redis. In this example, we will call the Redis GET command by calling the get method on the Redis facade:


As mentioned above, you may call any of Redis' commands on the Redis facade. Laravel uses magic methods to pass the commands to the Redis server. If a Redis command expects arguments, you should pass those to the facade's corresponding method:

    use Illuminate\Support\Facades\Redis;
    Redis::set('name', 'Taylor');
    $values = Redis::lrange('names', 5, 10);

Alternatively, you may pass commands to the server using the Redis facade's command method, which accepts the name of the command as its first argument and an array of values as its second argument:

    $values = Redis::command('lrange', ['name', 5, 10]);