Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Neurony/laravel-query-cache

Cache all {select} queries or only the duplicate ones for a specific Eloquent model
https://github.com/Neurony/laravel-query-cache

Last synced: 3 months ago
JSON representation

Cache all {select} queries or only the duplicate ones for a specific Eloquent model

Awesome Lists containing this project

README

        

# Package discontinued! Check out VARBOX.IO instead.

Unfortunately this package is now discontinued.
Please check out [Varbox](https://varbox.io) (Laravel Admin Panel) for this functionality and much more.

- Buy: [https://varbox.io/buy](https://varbox.io/buy)
- Docs: [https://varbox.io/docs](https://varbox.io/docs)
- Demo: [https://demo.varbox.test/admin](https://demo.varbox.test/admin)
- Repo [https://github.com/VarboxInternational/varbox](https://github.com/VarboxInternational/varbox)

Thank you!

---

### Cache all "select" queries or only the duplicate ones for a specific Eloquent model

[![Build Status](https://travis-ci.org/Neurony/laravel-query-cache.svg?branch=master)](https://travis-ci.org/Neurony/laravel-query-cache)
[![StyleCI](https://github.styleci.io/repos/177636041/shield?branch=master)](https://github.styleci.io/repos/177636041)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Neurony/laravel-query-cache/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Neurony/laravel-query-cache/?branch=master)

- [Overview](#overview)
- [Installation](#installation)
- [Usage](#usage)
- [Extra](#extra)

### Overview

This package allows you to cache all queries of type `select`, or only just the duplicated ones for an Eloquent model.

> Please note that because cache tagging is used, "file" or "database" cache drivers are incompatible with this package.
>
> **Compatible cache stores:** array, redis, apc, memcached
> **Tested cache stores:** array, redis

### Installation

Install the package via Composer:

```
composer require neurony/laravel-query-cache
```

Publish the config file with:

```
php artisan vendor:publish --provider="Neurony\QueryCache\ServiceProvider" --tag="config"
```

> Please read the `config/query-cache.php` config file comments as it contains extra information

### Usage

##### Step 1

Your Eloquent models should use the `Neurony\QueryCache\Traits\IsCacheable` trait.

```php
disableQueryCache();

/*
make your queries
the queries up until now won't be cached
*/

// from her on, apply query caching
app('cache.query')->enableQueryCache();

/*
make your queries
this queries will be cached
*/
```

### Credits

- [Andrei Badea](https://github.com/zbiller)
- [All Contributors](../../contributors)

### Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

### License

The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

### Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

### Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.