Skip to content

comoyi/redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis

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);

About

A redis class for PHP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages