Download the PHP package alesinicio/mutex without Composer

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

MUTEX

Simple PHP Mutex implementation.

Probably better suited for async applications where heavy-or-time-sensitive processes are executed in parallel with no intercommunication, and you need to implement some kind of semaphore.

Uses any PSR-16 (SimpleCache) implementation as the storage mechanism, just be sure to use something that all processes can access (in the likes of APC, memcached, Redis, plain files, etc...).

EXPLANATION

Mutexes are based on named events and timeouts. You lock an event for a certain period of time (or forever, if you wish), and then you can check elsewhere if that same event is locked or not, and act accordingly. Usually, your first process will lock the event just before you start doing some important operation, and unlock the event when you are finished. And then other processes that should wait for the first process to finish will check whether that event is locked and wait until it is clear to proceed.

BASIC EXAMPLE

Process #1 will start and put a lock in place for the event MyEvent, and unlock it after five seconds. Process #2 will check if there is a lock in place for the event. If there is, it will wait one second and check again, until process #1 unlocks it.

EXPLICIT TIMEOUT

Now process #1 will start and put a lock in place for the event MyEvent for a maximum time of 5 seconds, but will sleep for 10 seconds before trying to unlock it explicitly. Process #2 will check if there is a lock in place for the event. Every second it will check again. After the explicit 5 seconds timeout expires, the event will unlock automatically, event though Process #1 never released it explicitly.

IMPORTANT

The lock method returns a string ("lockID"). If the unlock method is called with a single parameter (event), it will unlock that event without any further checking. If the unlock method is called with a second parameter (lockID), it will unlock that event ONLY IF the lock was put in place by that same "lockID". This prevents the event from being unlocked by someone who did not put the lock in place.

SYNTACT SUGAR

The waitUntilUnlocked method handles the "waiting loop" for you, and some things more:

IMPORTANT CONSIDERATIONS


All versions of mutex with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/simple-cache Version 1|2|3
ext-posix 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 alesinicio/mutex contains the following files

Loading the files please wait ...