Download the PHP package dealerinspire/laravel-redlock without Composer

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

Laravel RedLock

A Laravel-friendly implementation of the Redis Redlock algorithm for distributed lock management.

Acknowledgements

This library was originally built by LibiChai based on the RedLock algorithm developed by antirez. The library was reworked by the team at That's Us, Inc. This project has been forked and maintained by Dealer Inspire Inc.

Installation

  1. composer require dealerinspire/laravel-redlock
  2. The RedLockServiceProvider should be Auto-discovered by Laravel. If not, add DealerInspire\RedLock\RedLockServiceProvider::class, to the providers array in config/app.php
  3. Enjoy!

Compatibility

Laravel Version RedLock Version
5.x ^4.0
6.x ^6.0
7.x ^7.0
8.x ^8.0
9.x ^9.0

It's Simple!

Set a lock on any scalar. If the lock() method returns false, you did not acquire the lock.

Store results of the lock() method. Use this value to release the lock with unlock().

Example

This example sets a lock on the key "1" with a 3 second expiration time.

If it acquired the lock, it does some work and releases the lock.

Refresh

Use refreshLock() to reacquire and extend the time of your lock.

Even Easier with Closures

Use runLocked() for nicer syntax. The method returns the results of the closure, or else false if the lock could not be acquired.

Refresh with Closures

You can easily refresh your tokens when using closures. The first parameter to your closure is $refresh. Simply call it when you want to refresh. If the lock cannot be refreshed, $refresh() will break out of the closure.

Lock Queue Jobs Easily

If you're running jobs on a Laravel queue, you may want to avoid queuing up the same job more than once at a time.

The DealerInspire\RedLock\Traits\QueueWithoutOverlap trait provides this functionality with very few changes to your job. Usually only two changes are necessary.

  1. use DealerInspire\RedLock\Traits\QueueWithoutOverlap as a trait
  2. Change the handle() method to handleSync()

Sometimes it's also necessary to specify a getLockKey() method. This method must return the string that needs to be locked.

This is typically unnecessary because the lock key can be generated automatically. But if the job's data is not easy to stringify, you must define the getLockKey() method.

This trait also provides a refresh method called refreshLock(). If refreshLock() is unable to refresh the lock, an exception is thrown and the job fails.

Finally, you can change the lock time-to-live from the default 300 seconds to another value using the $lock_time property.

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

Development

Development is done through simple use of the official PHP and Composer images.

Getting Started

  1. Pull down the repo.
  2. Install dependencies with bin/composer install
  3. That's it!

Run tests

Tests can be ran with bin/php vendor/bin/phpunit.

License

MIT


All versions of laravel-redlock with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
illuminate/support Version ^9.0
illuminate/console Version ^9.0
predis/predis Version ^2.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 dealerinspire/laravel-redlock contains the following files

Loading the files please wait ....