Download the PHP package karmabunny/rdb without Composer

On this page you can find all versions of the php package karmabunny/rdb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rdb

Rdb

Like Pdb, but for Redis. I guess.

This wraps existing Redis clients and normalises the API (between server versions and client implementations). It also introduces a few additional helpers:

Also because I don't want a hard dependency on either predis or php-redis. They both have their problems (vague magical commands API, binary extension, etc). Or wouldn't it be wonderful if a 3rd option showed up /s. Also supports credis.

Install

Add as a dependency:

Adapters

This library doesn't implement a redis client itself, only wraps existing clients. After much effort trying to normalise the responses from all these client, it might seem like a good idea to just write our own that isn't so inconsistent.

But consider that we only know how inconsistent these libraries are because we've spent so much time trying to make them all behave the same. For example, client 'A' might do 'B' well but 'C' badly. Then client 'D' does 'B' badly but 'C' really well.

So as I sit here and scoff at their feeble attempts, I am reminded of a few things:

  1. I've already introduced so many of my own bugs during this journey.
  2. Unit testing is a gift from heaven.
  3. Normalising these inconsistencies has improved our own consistency, something probably not as achievable when writing a new client from scratch.
  4. also this: https://xkcd.com/927

Version support

This wrapper doesn't try to polyfill any missing features. It targets Redis server v3.0, as that's the common support among all the adapters.

This library wouldn't ever try to hide features behind target versions, but perhaps it could help smooth out any differences. Lua scripting could polyfill a lot of things tbh.

For example, BRPOPLPUSH is deprecated in v6.2 and might be removed in the distant future. In this case, the library would be able to dynamically replace (based on the server version) this with BLMOVE.

Plans for v2

TTL params

There is a preference for the millisecond version of a command, particularly TTL parameters. This is clearly misleading and already wildly inconsistent. Ideally this changes so that a 'float' is converted to the millisecond version and integer remains unchanged. Thus the input is always 'seconds'. The implementation should include the 'p' millisecond version of each command, similar to how we've implemented incr/decr.

Type errors

Type errors are currently (hopefully) always a null return. This can quite confusing at times, or helpful in others. Version 2 will likely permit both, defaulting to emitting exceptions.

Object methods

The expected type in the object method is currently optional, but most drivers required it. Version 2 will make them required.

Config

Key Default Description
host 127.0.0.1 Server name + port
prefix '' Key prefix
adapter 'predis' Adapter type: predis, php-redis, credis
object_driver PhpObjectDriver Object driver class
timeout 5 Connection timeout, in seconds
lock_sleep 5 Tick size for locking, in milliseconds
chunk_size 50 Max key size for mscan methods
scan_size 1000 Count hint for scan methods
scan_keys false Replace keys() with scan()
options [] Adapter specific options

Notes:

Adapter options

Predis

The predis adapter accepts any options supported by the Predis client.

Option Description
use_predis_session Use the predis session handler
exceptions Enable exceptions on errors
connections Connection settings
cluster Cluster configuration
replication Replication configuration

PhpRedis

Option Description
use_native_session Use the native session handler
retry_interval Time between reconnection attempts
read_timeout Socket read timeout

Credis

Option Description
use_native_session only if standalone = false
standalone Force standalone mode vs phpredis

Object drivers

The object driver is responsible for serialising and deserialising objects for the 'object methods'.

These are:

Available drivers:

Usage

Basic usage with a TTL. Great for caching.

Object extensions will serialize in the PHP format. These have builtin assertions so things are always the correct shape.

Locking provides a mechanism to restrict atomic access to a resource.

Leaky bucket is a rate-limiting algorithm. It's cute, easy to understand, and not too complex.

Contributing

Submit a PR if you like. But before you do, please do the following:

  1. Run composer analyse and fix any complaints there
  2. Run composer compat and fix those too
  3. Write some tests and run composer tests
  4. Document the methods here

Methods

Core Methods

scalar:

sets:

lists:

sorted sets:

hashes:

Extended/Wrapper Methods

Builtin Utilities


All versions of rdb with dependencies

PHP Build Version
Package Version
Requires predis/predis Version ^2.2
colinmollenhour/credis Version ^1
php Version >=7.2
symfony/polyfill-php73 Version ^1.29
rybakit/msgpack Version ^0.9.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package karmabunny/rdb contains the following files

Loading the files please wait ....