Skip to content

Just another Redis Wrapper, around the phpredis/phpredis extension.

Notifications You must be signed in to change notification settings

mauriziofonte/php-redisw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Redis Wrapper around the phpredis extension

Just another Redis Wrapper, around the https://github.com/phpredis/phpredis extension.

Latest Stable Version Total Downloads

Installation

Simple enough.

composer require mfonte/redisw

Required environment:

  1. PHP >= 8.1
  2. ext-redis module
  3. 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.

About

Just another Redis Wrapper, around the phpredis/phpredis extension.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages