comoyi/redis

A redis class

Maintainers

Details

github.com/comoyi/redis

Source

Issues

Installs: 56

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/comoyi/redis

2.1.0 2017-04-05 13:34 UTC

This package is not auto-updated.

Last update: 2025-12-21 02:13:14 UTC


README

Installation

composer require comoyi/redis

Usage

<?php

use Comoyi\Redis\RedisClient;

$config = [
    'type' => 'direct', // direct: 直连, sentinel: 由sentinel决定host与port
    'password' => 'redispassword', // redis auth 密码
    'master_name' => 'mymaster', // master name
    'direct' => [
        'masters' => [
            [
                'host' => '127.0.0.1',
                'port' => '6379',
            ],
        ],
        'slaves' => [
            [
                'host' => '127.0.0.1',
                'port' => '6381',
            ],
            [
                'host' => '127.0.0.1',
                'port' => '6382',
            ],
        ],
    ],
    'sentinel' => [
        'sentinels' => [
            [
                'host' => '127.0.0.1',
                'port' => '5000',
            ],
            [
                'host' => '127.0.0.1',
                'port' => '5001',
            ],
        ],
    ],
];

$redis = new RedisClient($config);
$key = 'just-for-test';
$redis->set($key, 'test data');
$data = $redis->get($key);
var_dump($data);