master

laravel/framework

Last updated at: 29/12/2023 09:21

Connection.php

TLDR

This file contains the Connection interface that defines the contract for a Redis connection in Laravel.

Methods

subscribe

Subscribe to a set of given channels for messages. This method takes an array or string of channel names to subscribe to and a callback function to handle the received messages.

psubscribe

Subscribe to a set of given channels with wildcards. This method takes an array or string of channel names with wildcards to subscribe to and a callback function to handle the received messages.

command

Run a command against the Redis database. This method takes the name of the Redis command to run and an optional array of parameters. It returns the result of the command execution.

<?php

namespace Illuminate\Contracts\Redis;

use Closure;

interface Connection
{
    /**
     * 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 = []);
}