https://github.com/enikeishik/cachewithlock
CacheWithLock package for Laravel framework - overrides remember method of Laravel Cache using lock mechanism to avoid multiply generation of the same data.
https://github.com/enikeishik/cachewithlock
cache caching laravel laravel-package lock locking package php php-library
Last synced: about 1 year ago
JSON representation
CacheWithLock package for Laravel framework - overrides remember method of Laravel Cache using lock mechanism to avoid multiply generation of the same data.
- Host: GitHub
- URL: https://github.com/enikeishik/cachewithlock
- Owner: enikeishik
- License: gpl-3.0
- Created: 2021-09-13T11:21:10.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-02T07:02:32.000Z (over 4 years ago)
- Last Synced: 2025-01-08T21:27:47.294Z (over 1 year ago)
- Topics: cache, caching, laravel, laravel-package, lock, locking, package, php, php-library
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CacheWithLock
Package for [Laravel framework](https://laravel.com/) -
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](http://getcomposer.org/):
```bash
composer require enikeishik/cachewithlock
```
Make sure autoload will be changed:
```bash
composer dump-autoload
```
Publish package via artisan:
```bash
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:
```php
use CacheWithLock;
...
$value = CacheWithLock::remember(...);
...
```