Download the PHP package enaxon/reqtide-redis without Composer

On this page you can find all versions of the php package enaxon/reqtide-redis. 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 reqtide-redis

Reqtide Redis

Shared state for Reqtide, so several PHP processes obey one rate limit, one circuit breaker and one bulkhead.

This package is the Redis state backend of Reqtide PHP. Install it next to the core: composer require enaxon/reqtide enaxon/reqtide-redis. It is a beta (version 0.x): the API can change between minor versions. It was tested on the command line with PHP 8.3 to 8.5, Redis 7.4.11 and 8.2.10 and Predis 3.7, including TLS, and in one PHP-FPM lane. Redis 7.0 is the minimum. Sentinel, Cluster and Valkey are not supported.

What exists today

Item State
Rate limit (token bucket, fixed window, sliding counter), circuit breaker, bulkhead, retry budget, cooldown on Redis Works. One server-side script call for each step
RedisEnvironment: a ready RuntimeEnvironment for a pipeline Works
Redis 7.4.11 and 8.2.10, Predis 3.7, PHP 8.3 to 8.5 command line Tested locally in Docker, including TLS
Redis older than 7.0 Not supported: the scripts use redis.acl_check_cmd, which Redis 7.0 added. initialize() and inspectServer() refuse an older server, and every script fails before its first command on one
Redis Cluster Not supported by design; initialize() and inspectServer() refuse a server in Cluster mode. The scripts also touch keys they derive themselves (members of the registry index and entries of the tombstone queue), beyond the keys passed to them. The ACL pattern ~prefix:* covers those keys
PHP-FPM (PHP 8.4, nginx, six workers) Tested in CI: the state is shared by requests and workers, also under concurrent requests
Other PHP versions under FPM, Apache, Sentinel, Valkey, replicas Not tested, not supported

Set up

  1. Create one registry for each deployment. A registry is the isolation unit: a key prefix, an identity and two ceilings. The application never creates it.

  2. Give the application a user with only the rules in RedisAcl::execution($registry), and the host a user with RedisAcl::administration($registry).

Print the exact tokens with RedisAcl::execution($registry). The tests create users from these rules, run every operation, and remove one rule at a time: each rule is needed, and with one missing the first call fails as unavailable and writes nothing.

  1. Build the pipeline on the Redis environment. Creating it opens no connection.

  2. Run maintenance from a worker or a scheduler: (new RedisRegistryMaintenance($connection, $registry))->step() until more is false. It removes expired leases, finished cooldowns, expired records and idle partitions, 128 at a time. Nothing runs it for you.

Examples

examples/ holds three scripts that run against a local server: a rate limit shared by two pipelines, what happens when Redis is down, and explain() for shared state. From the development repository, tools/run-redis-examples.sh starts Redis in Docker, runs them and compares their output with examples/expected/.

Server settings

When something goes wrong

What happened What you get What was written
Server unreachable, TLS refused, password wrong, user lacks a rule, server full (noeviction) StateUnavailableException; the callable is not run Nothing
Connection lost or timed out after a command was sent IndeterminateStateException for a write, StateUnavailableException for a read; the library never sends it again Unknown for a write: it may have been applied once
Registry missing StateUnavailableException Nothing; the registry is not created
Stored data damaged CorruptStateException Nothing of the call. Cleanup of expired state that ran before the damage was found stays, and the registry counters stay in step with it
A key under the prefix holds a value of the wrong type CorruptStateException Nothing of the call
Registry ceiling reached StateCapacityExceededException, after expired state was reclaimed and the oldest finished records evicted Nothing

After an uncertain debit the operation is not run. After an uncertain release or finalization the result of your call is returned with incomplete accounting. After an uncertain retry commit no retry is sent.

Operator actions

Action Call
Close a circuit and make its permits stale RedisCircuitAdmin::reset($policyIdentity)
Retire a registry RedisRegistryAdmin::retire(), then purgeRetired() to remove what it left. initialize() refuses a prefix that still holds the index or the tombstone queue of a retired registry, and purgeRetired() refuses to run while the registry exists
Check the server policy RedisRegistryAdmin::inspectServer() (needs CONFIG GET and INFO)

Cost of one call

A script call is atomic and blocks the server while it runs. Most calls touch a few keys. Two paths cost time in proportion to the records of one partition: a circuit that changes state removes every permit it still holds, and a concurrency partition removes the leases that expired. Both are bounded by the registry ceiling maxRecords, which can be up to 1,000,000. Keep maxRecords as low as the load needs.

Not planned for the first release

Redis Sentinel, Redis Cluster, Valkey, and protection that survives data loss on restart or failover.

License

MIT.


All versions of reqtide-redis with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-openssl Version *
predis/predis Version ^3.7
enaxon/reqtide Version self.version
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 enaxon/reqtide-redis contains the following files

Loading the files please wait ...