mfonte / redisw
A Redis Client implementation library, built on top of the phpredis PECL package.
Requires
- php: ^8.1
- ext-redis: >=2.2.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- mockery/mockery: ^1.3.3
- orchestra/testbench: ^7.0
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.5
README
Just another Redis Wrapper, around the https://github.com/phpredis/phpredis extension.
Installation
Simple enough.
composer require mfonte/redisw
Required environment:
- PHP >= 8.1
ext-redis
module- optional (but recommended) : igbinary support for better serialization
Basic Usage
Usage is simple enough with a nice, expressive API:
<?php use Mfonte\Redisw\RedisClient as Redisw; try { $client = Redisw::instance([ 'host' => '127.0.0.1', 'port' => 6379, 'connect_timeout' => 1, // optional 'connect_tries' => 10, // optional 'persistent' => true, // optional 'db_index' => 1, // optional 'cache_ttl' => 60, // optional. Defaults to 60 sec. 'auth_password' => '', // optional 'ssl' => '', // optional 'key_prefix' => 'some_prefix', // optional 'serializer' => 'ibginary', // optional. One of: igbinary, json, php 'compression' => 'lzf', // optional. One of: lzf, zstd, lz4 ]); // set a key $client->set('somekey', ['value', 'value', 'value']); // get a key $value = $client->get('somekey'); } catch(\Exception $ex) { echo "Something got wrong: {$ex->getMessage()}"; } // don't want exceptions while setting/getting/whatever? $client->wrap('set', 'wont-throw-exceptions', [1, 2, 3, 4]); $value = $client->wrap('get', 'wont-throw-exceptions');
Testing
Simply run composer install
over this module's installation directory.
Then, run composer test
to run all the tests.
Thank you's
A big thank you goes to https://github.com/alxmsl for his base implementation on https://github.com/alxmsl/Redis. This package heavily relies on his work.
Another big thank you goes to https://github.com/ukko for his phpredis extension autocomplete on https://github.com/ukko/phpredis-phpdoc. This package was easier to be written thanks to his work.