All Projects → cheprasov → Php Redis Client

cheprasov / Php Redis Client

Licence: mit
RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

Projects that are alternatives of or similar to Php Redis Client

Redis
Type-safe Redis client for Golang
Stars: ✭ 13,117 (+11611.61%)
Mutual labels:  redis, redis-client, redis-cluster
Ioredis
🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
Stars: ✭ 9,754 (+8608.93%)
Mutual labels:  redis, redis-client, redis-cluster
Camellia
camellia framework by netease-im. provider: 1) redis-client; 2) redis-proxy(redis-sentinel/redis-cluster); 3) hbase-client; 4) others
Stars: ✭ 146 (+30.36%)
Mutual labels:  redis, redis-client, redis-cluster
Cachingframework.redis
Distributed caching based on StackExchange.Redis and Redis. Includes support for tagging and is cluster-compatible.
Stars: ✭ 209 (+86.61%)
Mutual labels:  redis, redis-client, redis-cluster
Lettuce Core
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Stars: ✭ 4,319 (+3756.25%)
Mutual labels:  redis, redis-client, redis-cluster
Csredis
.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
Stars: ✭ 1,714 (+1430.36%)
Mutual labels:  redis, redis-client, redis-cluster
Hiredis Vip
Support redis cluster. Maintained and used at vipshop.
Stars: ✭ 274 (+144.64%)
Mutual labels:  redis, redis-cluster, client
Redis Game Transaction
在大型游戏中经常使用分布式,分布式中因为游戏逻辑会经常游戏事务,借助redis特性我们可以实现分布式锁和分布式事务。很多redis集群不支持redis的事务特性。 这个框架用来解决分布式服务器下redis集群事务失效的情况下,基于分布式锁完成分布式事务。支持独占锁,共享锁,读写锁,并且支持事务提交失败情况下的回滚操作,让开发者可以有更多时间侧重游戏逻辑.
Stars: ✭ 124 (+10.71%)
Mutual labels:  redis, redis-client, redis-cluster
Fastoredis
FastoRedis is a crossplatform Redis GUI management tool.
Stars: ✭ 316 (+182.14%)
Mutual labels:  redis, redis-client, redis-cluster
Xredis
Redis C++ client, support the data slice storage, support redis cluster, thread-safe,multi-platform,connection pool, read/write separation.
Stars: ✭ 285 (+154.46%)
Mutual labels:  redis, redis-client, redis-cluster
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+15946.43%)
Mutual labels:  redis, redis-client, redis-cluster
Quick redis blog
QuickRedis is a free forever Redis Desktop manager. It supports direct connection, sentinel, and cluster mode, supports multiple languages, supports hundreds of millions of keys, and has an amazing UI. Supports both Windows, Mac OS X and Linux platform.
Stars: ✭ 594 (+430.36%)
Mutual labels:  redis, redis-client, redis-cluster
Redis Plus Plus
Redis client written in C++
Stars: ✭ 428 (+282.14%)
Mutual labels:  redis, redis-client, redis-cluster
Redis Py Cluster
Python cluster client for the official redis cluster. Redis 3.0+.
Stars: ✭ 934 (+733.93%)
Mutual labels:  redis, redis-client, redis-cluster
Docker Redis Cluster
Running a distributed 6-node Redis Cluster with Docker Swarm, Docker Compose, and Supervisor
Stars: ✭ 39 (-65.18%)
Mutual labels:  redis, redis-cluster
Predixy
A high performance and fully featured proxy for redis, support redis sentinel and redis cluster
Stars: ✭ 862 (+669.64%)
Mutual labels:  redis, redis-cluster
Fastonosql
FastoNoSQL is a crossplatform Redis, Memcached, SSDB, LevelDB, RocksDB, UnQLite, LMDB, ForestDB, Pika, Dynomite, KeyDB GUI management tool.
Stars: ✭ 1,001 (+793.75%)
Mutual labels:  redis, redis-cluster
Php Redis Implementation
Raw wrapper for real Redis fans.
Stars: ✭ 48 (-57.14%)
Mutual labels:  redis, redis-client
Cpp redis
C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform - NO LONGER MAINTAINED - Please check https://github.com/cpp-redis/cpp_redis
Stars: ✭ 855 (+663.39%)
Mutual labels:  redis, redis-client
Docker Redis Cluster
Dockerfile for Redis Cluster (redis 3.0+)
Stars: ✭ 1,035 (+824.11%)
Mutual labels:  redis, redis-cluster

MIT license Latest Stable Version Total Downloads

RedisClient v1.10.0 for PHP >= 5.5

About

RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

Main features

  • Support Redis versions from 2.6.x to 6.0.x.
  • Support TCP/IP and UNIX sockets.
  • Support PubSub and Monitor functionallity.
  • Support Pipeline and Transactions.
  • Support Redis Cluster.
  • Support RAW commands as arrays ['SET', 'foo', 'bar'].
  • Connections to Redis are established lazily by the client upon the first command.
  • Easy to use with IDE, client has PHPDocs for all supported versions.
  • By default, the client works with the latest stable version of Redis (6.0).
  • The client was tested on the next latest versions of Redis: 6.0.5, 5.0.5, 4.0.14, 3.2.8, 3.0.7, 2.8.24, 2.6.17.
  • Also, the client was tested on PHP 7.4, 7.3, 7.2, 7.1, 7.0, 5.6, 5.5, HHVM.

Redis Commands

Please see list of commands here ./COMMANDS.md

Usage

Config

$config = [
    // Optional. Default = '127.0.0.1:6379'. You can use 'unix:///tmp/redis.sock'
    'server' => '127.0.0.1:6379',

    // Optional. Default = 1
    // The timeout for reading/writing data over the socket
    'timeout' => 2,

    // Optional. Default = null
    // See more here: http://php.net/manual/en/function.stream-socket-client.php
    'connection' => [
        // Optional. Default = ini_get("default_socket_timeout")
        // The timeout only applies while making connecting the socket
        'timeout' => 2,

        // Optional. Default = STREAM_CLIENT_CONNECT
        // Bitmask field which may be set to any combination of connection flags.
        // Currently the select of connection flags is limited to STREAM_CLIENT_CONNECT (default),
        // STREAM_CLIENT_ASYNC_CONNECT and STREAM_CLIENT_PERSISTENT.
        'flags' => STREAM_CLIENT_CONNECT
    ],

    // Optional. Specify version to avoid some unexpected errors.
    'version' => '4.0.10',

    // Optional. Use it only if Redis server requires password (AUTH)
    'password' => 'some-password',

    // Optional. Use it, if you want to select not default db (db != 0) on connect
    'database' => 1,

    // Optional. Array with configs for RedisCluster support
    'cluster' => [
        'enabled' => false,

        // Optional. Default = []. Map of cluster slots and servers
        // array(max_slot => server [, ...])
        // Examples for Cluster with 3 Nodes:
        'clusters' => [
            5460  => '127.0.0.1:7001', // slots from 0 to 5460
            10922 => '127.0.0.1:7002', // slots from 5461 to 10922
            16383 => '127.0.0.1:7003', // slots from 10923 to 16383
        ],

        // Optional. Default = false.
        // Use the param to update cluster slot map below on init RedisClient.
        // RedisClient will execute command CLUSTER SLOTS to get map.
        'init_on_start' => false,

        // Optional. Default = false.
        // If Redis returns error -MOVED then RedisClient will execute
        // command CLUSTER SLOTS to update cluster slot map
        'init_on_error_moved' => true,

        // Optional. Defatult = 0.05 sec. It is timeout before next attempt on TRYAGAIN error.
        'timeout_on_error_tryagain' => 0.25, // sec
    ]
];

Create a new instance of RedisClient

<?php
namespace Examples;

require (dirname(__DIR__).'/vendor/autoload.php');
// or require (dirname(__DIR__).'/src/autoloader.php');

use RedisClient\RedisClient;
use RedisClient\Client\Version\RedisClient2x6;
use RedisClient\ClientFactory;

// Example 1. Create new Instance for Redis version 6.0.x with config via factory
$Redis = ClientFactory::create([
    'server' => '127.0.0.1:6379', // or 'unix:///tmp/redis.sock'
    'timeout' => 2,
    'version' => '6.0'
]);

echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 2.8


// Example 2. Create new Instance without config. Client will use default config.
$Redis = new RedisClient();
// By default, the client works with the latest stable version of Redis.
echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 3.2
echo 'Redis: '. $Redis->info('Server')['redis_version'] . PHP_EOL; // Redis: 3.0.3


// Example 3. Create new Instance with config
// By default, the client works with the latest stable version of Redis.
$Redis = new RedisClient([
    'server' => '127.0.0.1:6387', // or 'unix:///tmp/redis.sock'
    'timeout' => 2
]);

echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 3.2
echo 'Redis: '. $Redis->info('Server')['redis_version'] . PHP_EOL; // Redis: 3.2.0


// Example 4. Create new Instance for Redis version 2.6.x with config
$Redis = new RedisClient2x6([
    'server' => 'tcp://127.0.0.1:6379', // or 'unix:///tmp/redis.sock'
    'timeout' => 2
]);

echo 'RedisClient: '. $Redis->getSupportedVersion() . PHP_EOL; // RedisClient: 2.6

Example

Please, see examples here: https://github.com/cheprasov/php-redis-client/tree/master/examples

Installation

Composer

Download composer:

wget -nc http://getcomposer.org/composer.phar

and add dependency to your project:

php composer.phar require cheprasov/php-redis-client

Running tests

  1. Run Docker container with Redis for tests https://hub.docker.com/r/cheprasov/redis-for-tests/

  2. Run Docker container with Redis Cluster for tests https://hub.docker.com/r/cheprasov/redis-cluster-for-tests/

  3. To run tests type in console:

    ./vendor/bin/phpunit

Something doesn't work

Feel free to fork project, fix bugs and finally request for pull

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].