llegaz/redis-adapter

additional layer based on phpredis/phpredis and predis/predis

0.0.4 2025-03-12 13:38 UTC

This package is auto-updated.

Last update: 2025-06-12 14:43:28 UTC


README

Intro

This project isn't really an adapter, for me, it is a sort of GATEWAY. (see Martin Fowler, Gateway Pattern).

The goal here is to adapt use of either Predis client or native PHP Redis client in a transparently way. Those are the real adaptees, their respective classes are extended to adapt them to the gateway (RedisAdapter) that will encapsulate one of them (as a redis client) and use one or the other indifferently depending on environment.

It will use preferably PHP Redis if available (extension installed), or else fallback on predis.

This class settles base for other projects based on it (PSR-6 Cache and so on)

Install

composer require llegaz/redis-adapter
composer install

env

In order to work this need php8 and some classical php extensions plus a local redis server (for testing purpose) and docker to test multiples instances of redis servers.

apt install php8.1 php8.1-cli php8.1-common php8.1-mbstring php8.1-opcache

and perhaps other packages are required for composer to work smoothly

apt install php8.1-xml php8.1-http php8.1-dom

Dev

install redis servers with docker (you will need a valid docker and docker-compose on your system)

docker pull redis
docker-compose -f docker-compose.yml up -d

Contributing

You're welcome to propose things. I am open to criticism as long as it remains benevolent.

Stay tuned, by following me on github, for new features using predis and PHP Redis.

@see you space cowboy