Download the PHP package roadrunner-php/lock without Composer

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

RoadRunner

Distributed locks for PHP applications powered by RoadRunner

[![Documentation](https://img.shields.io/badge/Documentation-blue?style=for-the-badge&logo=gitbook&logoColor=white)](https://docs.roadrunner.dev/docs/plugins/locks) [![Sponsor](https://img.shields.io/static/v1?style=for-the-badge&label=&message=Sponsor&logo=githubsponsors&logoColor=white&color=%23EA4AAA)](https://github.com/sponsors/roadrunner-server) [![Psalm Level](https://shepherd.dev/github/roadrunner-php/lock/level.svg)](https://shepherd.dev/github/roadrunner-php/lock) [![Type Coverage](https://shepherd.dev/github/roadrunner-php/lock/coverage.svg)](https://shepherd.dev/github/roadrunner-php/lock) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Froadrunner-php%2Flock%2F1.x)](https://dashboard.stryker-mutator.io/reports/github.com/roadrunner-php/lock/1.x)


This package is a PHP client for the RoadRunner Lock plugin. It lets your workers acquire, release and manage exclusive and shared (read) locks on named resources, shared across all processes connected to the RoadRunner server.

Get Started

Requirements

Make sure that your server is configured with following PHP version and extensions:

Installation

PHP Latest Version on Packagist Total Downloads

Configuration

The client talks to RoadRunner over RPC, so enable the rpc section in .rr.yaml. The Lock plugin uses the in-memory backend by default; see the plugin documentation to share locks between RoadRunner instances through Redis.

Your First Lock

Create a Lock instance with an RPC connection to the RoadRunner server, then acquire and release a lock:

Usage

Acquire lock

Locks a resource so that it can be accessed by one process at a time.

By default the call is non-blocking: if the resource is already locked, it returns false almost immediately (the RoadRunner server caps the default waitTTL window at 1ms). Pass a positive waitTTL to block until the lock is released — the call then returns the lock id as soon as the lock becomes free, or false when the waitTTL timeout elapses.

Acquire read lock

Locks a resource for shared access, allowing multiple processes to access the resource simultaneously. When a resource is locked for shared access, other processes that attempt to lock the resource for exclusive access will fail to do so while any shared lock is held.

As with lock(), the waitTTL parameter is non-blocking by default (false is returned almost immediately, within the server's 1ms window); pass a positive waitTTL to block for up to that duration for the lock to become available.

Lock parameters

Both lock() and lockRead() accept the same arguments:

Parameter Type Default Description
resource non-empty-string — Name of the resource to lock.
id non-empty-string|null null Lock owner id. When omitted a random UUID is generated. Keep it — the same id must be passed to release().
ttl int|float|DateInterval 0 (forever) Lock lifetime, in seconds. When it elapses the lock is released automatically; 0 means it never expires on its own.
waitTTL int|float|DateInterval 0 (~1ms) How long to wait for the lock to become free, in seconds. 0 is effectively non-blocking — the server caps it at 1ms, so false is returned almost immediately when the resource is already locked. A positive value blocks for up to that duration, then returns false on timeout.

Both methods return the lock id (non-empty-string) when the lock is acquired, or false when it is not (the resource stayed busy until the waitTTL window elapsed).

ttl and waitTTL are expressed in seconds (int or float), or as a DateInterval.

Release lock

Releases an exclusive lock or read lock on a resource that was previously acquired by a call to lock() or lockRead().

Check lock

Checks if a resource is currently locked. Pass a lock id to check whether that particular lock is held.

Update TTL

Updates the time-to-live (TTL) for the locked resource.

Testing

Credits


All versions of lock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ramsey/uuid Version ^4.7
roadrunner/api-dto Version ^2.1
roadrunner/goridge Version ^4.5
roadrunner/roadrunner Version ^3.0
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 roadrunner-php/lock contains the following files

Loading the files please wait ...