Skip to content

Latest commit

 

History

History
53 lines (33 loc) · 1.02 KB

README.md

File metadata and controls

53 lines (33 loc) · 1.02 KB

CacheWithLock

Package for Laravel framework - overrides remember method of Laravel Cache using lock mechanism to avoid multiply generation of the same data (as a result of race condition) when cache becomes invalid.

Requirements

  • PHP >= 7.4
  • Laravel >= 7.0

Install

Install (or update) package via composer:

composer require enikeishik/cachewithlock

Make sure autoload will be changed:

composer dump-autoload

Publish package via artisan:

php artisan vendor:publish --provider="Enikeishik\CacheWithLock\ServiceProvider"

This command copy configuration file into corresponding project folder.

Usage

Package service provider contains an extend call to override Laravel Cache class. So there is no need to make any changes in code.

Overriding can be disabled in package configuration.

Without overriding Laravel Cache use CacheWithLock facade:

use CacheWithLock;

...

$value = CacheWithLock::remember(...);

...