Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

[Proposal][5.4] Add Redis connection contract #399

Closed
hskrasek opened this issue Feb 2, 2017 · 1 comment
Closed

[Proposal][5.4] Add Redis connection contract #399

hskrasek opened this issue Feb 2, 2017 · 1 comment

Comments

@hskrasek
Copy link

hskrasek commented Feb 2, 2017

In Laravel 5.4, the old Illuminate\Redis\Database class was replaced with Illuminate\Redis\RedisManager. This new class returns either a Illuminate\Redis\Connections\PredisConnection or a Illuminate\Redis\Connections\PhpRedisConnection, both of which extend Illuminate\Redis\Connections\Connection.

Unfortunately neither of those classes extend an interface that can be type hinted against, so I propose we either add a Illuminate\Contracts\Redis\Connections\Connection interface or a Illuminate\Redis\Connections\ConnectionInterface

Potential Interface:

<?php

namespace Illuminate\Redis\Connections;

use Closure;

interface ConnectionInterface
{
    /**
     * Subscribe to a set of given channels for messages.
     *
     * @param  array|string  $channels
     * @param  \Closure  $callback
     * @return void
     */
    public function subscribe($channels, Closure $callback);

    /**
     * Subscribe to a set of given channels with wildcards.
     *
     * @param  array|string  $channels
     * @param  \Closure  $callback
     * @return void
     */
    public function psubscribe($channels, Closure $callback);

    /**
     * Run a command against the Redis database.
     *
     * @param  string  $method
     * @param  array   $parameters
     * @return mixed
     */
    public function command($method, array $parameters = []);
}
@taylorotwell
Copy link
Member

Generally fine with me if someone wants to PR something simple.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants