shen2/easy-redis

an async redis wrapper for phpredis

v1.0 2017-12-29 10:05 UTC

This package is auto-updated.

Last update: 2024-09-23 19:08:18 UTC


README

an async redis wrapper for phpredis

Features

  • Using phpredis extension (nicolasff/phpredis)
  • Support asynchronous and synchronous request
  • Support for logged, unlogged and counter batches

Installation

PHP 5.4+ is required. phpredis extension is required.

Append dependency into composer.json

	...
	"require": {
		...
		"shen2/easy-redis": "dev-master"
	}
	...

Basic Using

<?php

$config = array(
	'host'		=> 'localhost',
	'port'		=> 6379,
	'persistent'=> false,
	'database'	=> 0,
	'profiler'	=> true,
);

// Create a connection.
$redisManager = new EasyRedis\Manager($config);

// send request synchronously.
$redisManager->send('set', ['a', 'abc']);
echo $redisManager->send('get', ['a']) . "\n";

// send request asynchronously
$redisManager->sendAsync('set', ['a', 'abc']);

$redisManager->sendAsync('set', ['b', '123'])->then(function(){
    echo "successed.\n";
});