Code Monkey home page Code Monkey logo

laravel-model-caching's Introduction

Model Caching for Laravel

Laravel Package Scrutinizer BCH Compliance Coveralls GitHub (pre-)release Packagist GitHub license

Model Caching for Laravel masthead image

Supporting This Package

This is an MIT-licensed open source project with its ongoing development made possible by the support of the community. If you'd like to support this, and our other packages, please consider becoming a sponsor.

We thank the following sponsors for their generosity, please take a moment to check them out:

Impetus

I created this package in response to a client project that had complex, nested forms with many <select>'s that resulted in over 700 database queries on one page. I needed a package that abstracted the caching process out of the model for me, and one that would let me cache custom queries, as well as cache model relationships. This package is an attempt to address those requirements.

Features

  • automatic, self-invalidating relationship (only eager-loading) caching.
  • automatic, self-invalidating model query caching.
  • automatic use of cache tags for cache providers that support them (will flush entire cache for providers that don't).

Cache Drivers

This package is best suited for taggable cache drivers:

+ Redis
+ MemCached
+ APC
+ Array

It will not work with non-taggable drivers:

- Database
- File
- DynamoDB

Requirements

  • PHP 7.3+
  • Laravel 8.0+
    - Please note that prior Laravel versions are not supported and the package
    - versions that are compatible with prior versions of Laravel contain bugs.
    - Please only use with the versions of Laravel noted above to be compatible.

Possible Package Conflicts

Any packages that override newEloquentModel() from the Model class will likely conflict with this package. Of course, any packages that implement their own Querybuilder class effectively circumvent this package, rendering them incompatible.

The following are packages we have identified as conflicting:

Things That Don't Work Currently

The following items currently do no work with this package:

- caching of lazy-loaded relationships, see #127. Currently lazy-loaded belongs-to relationships are cached. Caching of other relationships is in the works.
- using select() clauses in Eloquent queries, see #238 (work-around discussed in the issue)
- using transactions. If you are using transactions, you will likely have to manually flush the cache, see [issue #305](https://github.com/GeneaLabs/laravel-model-caching/issues/305).

installation guide cover

Installation

Be sure to not require a specific version of this package when requiring it:

composer require genealabs/laravel-model-caching

Gotchas If Using With Lumen

The following steps need to be figured out by you and implemented in your Lumen app. Googling for ways to do this provided various approaches to this.

  1. Register the package to load in Lumen:
    $app->register(GeneaLabs\LaravelModelCaching\Providers\Service::class);
  2. Make sure your Lumen app can load config files.
  3. Publish this package's config file to the location your app loads config files from.

Upgrade Notes

0.6.0

The environment and config variables for disabling this package have changed.

  • If you have previously published the config file, publish it again, and adjust as necessary:

    php artisan modelCache:publish --config
  • If you have disabled the package in your .env file, change the entry from MODEL_CACHE_DISABLED=true to MODEL_CACHE_ENABLED=false.

0.5.0

The following implementations have changed (see the respective sections below):

  • model-specific cache prefix

Configuration

Recommended (Optional) Custom Cache Store

If you would like to use a different cache store than the default one used by your Laravel application, you may do so by setting the MODEL_CACHE_STORE environment variable in your .env file to the name of a cache store configured in config/cache.php (you can define any custom cache store based on your specific needs there). For example:

MODEL_CACHE_STORE=redis2

Usage

For best performance a taggable cache provider is recommended (redis, memcached). While this is optional, using a non-taggable cache provider will mean that the entire cache is cleared each time a model is created, saved, updated, or deleted.

For ease of maintenance, I would recommend adding a BaseModel model that uses Cachable, from which all your other models are extended. If you don't want to do that, simply extend your models directly from CachedModel.

Here's an example BaseModel class:

<?php namespace App;

use GeneaLabs\LaravelModelCaching\Traits\Cachable;

abstract class BaseModel
{
    use Cachable;
    //
}

Multiple Database Connections

Thanks to @dtvmedia for suggestion this feature. This is actually a more robust solution than cache-prefixes.

Keeping keys separate for multiple database connections is automatically handled. This is especially important for multi-tenant applications, and of course any application using multiple database connections.

Optional Cache Key Prefix

Thanks to @lucian-dragomir for suggesting this feature! You can use cache key prefixing to keep cache entries separate for multi-tenant applications. For this it is recommended to add the Cachable trait to a base model, then set the cache key prefix config value there.

Here's is an example:

<?php namespace GeneaLabs\LaravelModelCaching\Tests\Fixtures;

use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class BaseModel extends Model
{
    use Cachable;

    protected $cachePrefix = "test-prefix";
}

The cache prefix can also be set in the configuration to prefix all cached models across the board:

    'cache-prefix' => 'test-prefix',

Exception: User Model

I would not recommend caching the user model, as it is a special case, since it extends Illuminate\Foundation\Auth\User. Overriding that would break functionality. Not only that, but it probably isn't a good idea to cache the user model anyway, since you always want to pull the most up-to-date info on it.

Experimental: Cache Cool-down In Specific Models

In some instances, you may want to add a cache invalidation cool-down period. For example you might have a busy site where comments are submitted at a high rate, and you don't want every comment submission to invalidate the cache. While I don't necessarily recommend this, you might experiment it's effectiveness.

To use it, it must be enabled in the model (or base model if you want to use it on multiple or all models):

class MyModel extends Model
{
    use Cachable;

    protected $cacheCooldownSeconds = 300; // 5 minutes

    // ...
}

After that it can be implemented in queries:

(new Comment)
    ->withCacheCooldownSeconds(30) // override default cooldown seconds in model
    ->get();

or:

(new Comment)
    ->withCacheCooldownSeconds() // use default cooldown seconds in model
    ->get();

Disabling Caching of Queries

There are two methods by which model-caching can be disabled:

  1. Use ->disableCache() in a query-by-query instance.
  2. Set MODEL_CACHE_ENABLED=false in your .env file.
  3. If you only need to disable the cache for a block of code, or for non- eloquent queries, this is probably the better option:
    $result = app("model-cache")->runDisabled(function () {
        return (new MyModel)->get(); // or any other stuff you need to run with model-caching disabled
    });

Recommendation: use option #1 in all your seeder queries to avoid pulling in cached information when reseeding multiple times. You can disable a given query by using disableCache() anywhere in the query chain. For example:

$results = $myModel->disableCache()->where('field', $value)->get();

Manual Flushing of Specific Model

You can flush the cache of a specific model using the following artisan command:

php artisan modelCache:clear --model=App\Model

This comes in handy when manually making updates to the database. You could also trigger this after making updates to the database from sources outside your Laravel app.

Summary

That's all you need to do. All model queries and relationships are now cached!

In testing this has optimized performance on some pages up to 900%! Most often you should see somewhere around 100% performance increase.

Commitment to Quality

During package development I try as best as possible to embrace good design and development practices, to help ensure that this package is as good as it can be. My checklist for package development includes:

  • ✅ Achieve as close to 100% code coverage as possible using unit tests.
  • ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer.
  • ✅ Be fully PSR1, PSR2, and PSR4 compliant.
  • ✅ Include comprehensive documentation in README.md.
  • ✅ Provide an up-to-date CHANGELOG.md which adheres to the format outlined at https://keepachangelog.com.
  • ✅ Have no PHPMD or PHPCS warnings throughout all code.

Contributing

Please observe and respect all aspects of the included Code of Conduct https://github.com/GeneaLabs/laravel-model-caching/blob/master/CODE_OF_CONDUCT.md.

Reporting Issues

When reporting issues, please fill out the included template as completely as possible. Incomplete issues may be ignored or closed if there is not enough information included to be actionable.

Submitting Pull Requests

Please review the Contribution Guidelines https://github.com/GeneaLabs/laravel-model-caching/blob/master/CONTRIBUTING.md. Only PRs that meet all criterium will be accepted.

If you ❤️ open-source software, give the repos you use a ⭐️.

We have included the awesome symfony/thanks composer package as a dev dependency. Let your OS package maintainers know you appreciate them by starring the packages you use. Simply run composer thanks after installing this package. (And not to worry, since it's a dev-dependency it won't be installed in your live environment.)

laravel-model-caching's People

Contributors

alexhampu avatar cinco-de-mauro avatar cluebattery avatar d8vjork avatar dependabot-preview[bot] avatar dmason30 avatar faytekin avatar fridzema avatar hornet-wing avatar imunew avatar jacobzlogar avatar jamesrus52 avatar jason-klein avatar joshuadwire avatar kieranfyi avatar laravel-shift avatar markryandelarmente avatar mikebronner avatar nope7777 avatar peter-brennan avatar pokeguys avatar rs-sliske avatar rssawhney avatar saernz avatar sjbronner avatar smskin avatar spencer-leopold avatar titrxw avatar tmishutin avatar vheins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-model-caching's Issues

Provide method to limit invalidation of specific models for specific periods of time.

Continuation of discussion from #59.

My thoughts on this are the following:

  • developer provides a protected property on a model that defines the minimum period for which its cache will not be invalidated.
  • invalidation mechanism will check for existence of that property, and compare it against a cache value that identifies the model and the timestamp of last invalidation.
  • invalidation will proceed if sufficient time has passed as defined by the protected property on the model.
  • after invalidation, the cache value for that model will be reset with a new timestamp.

If a model does not contain the protected property, none of the above will take place, and cache invalidation will proceed as normal.

Redis Caching Needs Debugging

When working through some issues, I discovered that redis caching may not be working properly in some cases. I am working on debugging this. There seems to be an issue with cursor queries.

not taking param into consideration?

So I have a query such as this. and i have an api endpoint categories/id/products..

$collection = ProductVariant::with( 'product.owner' )->whereHas( 'product', function( $q ) use ( $categoryId )
            {
                $q->whereCategoryId($categoryId)->live();
            } )->inRandomOrder()->live(1)

but when i change the id to say 2 or 3.. I get same products.. is this something I have to take care of? or am i doing something wrong?

Environment

Laravel Version: 5.6.2
Laravel Model Caching Package Version: ^0.2.22
PHP Version: * 7.1.6 *
Homestead Version: N/A (using Valet)
Operating System & Version: *Mac OS - El captain - 10.11.6 *

Optimize Cache Keys

Currently cache keys can be extraordinarily long, which might cause an issue if max key length is reached.

To prevent this, I had the idea of generating cache keys the same way they are now, but then using their hash as the key.

This will reduce key size, as well as obfuscate its content. (That would only be important for encrypted data, which it currently is not, but could also be a future consideration.)

I could see this being a quick little project for you. Please let me know your thoughts on the concept (pros/cons), and if you would be interested in it.

disableCache() only works sometimes

Issue

When calling disableCache() on a query that uses a custom scope (I think this is what's causing it) it only works sometimes.

Environment

Laravel Version: 5.6.3
Laravel Model Caching Package Version: 0.2.33
PHP Version: 7.2.2
Homestead Version: N/A
Operating System & Version: macOS High Sierra 10.13.3

Stack Trace

As you can see the following query works on and off. After it fails it will work and vice-versa.

disablecache -test0

The scope pendingGroupInvites is defined by:

public function scopePendingGroupInvites($query, $groupID)
{
    return $query->where([['type', GroupInvite::class], ['data->group->id', $groupID]])->whereNull('data->action');
}

The following query always works:

Group::find(1)->users()->disableCache()->get();

In this case users is a many-to-many relationship.

As a final note, I'm using Redis.

disableCache()-stacktrace.txt

add cache driver option in abstract class

Issue

using different cache driver for model caching other than the app specific cache driver

Environment

Laravel Version: 5.5.25
Laravel Model Caching Package Version: 0.2.12
PHP Version: 7.1.11

Operating System & Version: Ubuntu 16.04

Parse `doesnthave()` condition and add to cache key

Issue

It has to be created cache for when tried to retrieve from a model, some result that we doesn't want a relationship attached.

For example: Authors that does not have books:
$authors = collect([(new Author)->doesntHave('books')->first()]);

Stack Trace

Currently, if we try to execute the method, we have this stack:

ErrorException: Undefined index: column

/home/vagrant/Code/laravel-model-caching/src/CachedBuilder.php:106
/home/vagrant/Code/laravel-model-caching/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1197
/home/vagrant/Code/laravel-model-caching/src/CachedBuilder.php:107
/home/vagrant/Code/laravel-model-caching/src/CachedBuilder.php:28
/home/vagrant/Code/laravel-model-caching/src/CachedBuilder.php:203

Update readme

Add more detailed information for

  • setting up dedicated model-cache store
  • flushing the dedicated model-cache store
  • update the wording to have a dedicated model-cache store be the default

This could be down to my weird use case

Issue

I have a complex query:

select * from `profiles` where (profiles.user_id not in(?) and profiles.active = 1)
                and (profiles.user_id in(select user_id from user_interests where interest_id in(?))
                    or profiles.user_id in(select user_id from user_locations where region_id in(?))
                        or profiles.user_id in(select user_id from profiles where country_id = ?))

which I call like this:

  $data['suggestedConnections'] = Profile::whereRaw('(profiles.user_id not in(?) and profiles.active = 1)
            and (profiles.user_id in(select user_id from user_interests where interest_id in(?))
                or profiles.user_id in(select user_id from user_locations where region_id in(?))
                    or profiles.user_id in(select user_id from profiles where country_id = ?))',
                array($excludedIds, $includedInterests, $includedRegions, $location))
            ->limit(10)
            ->inRandomOrder()
            ->get();

$excludedIds, $includedInterests, $IncludedRegions are all arrays of ids
and $location is an integer.

I really don't want this query to be cached (or maybe a better way to put it is that I want this query to be excluded from the query cache, but I want the rest of the queries on the model to be cached).

I'm wondering if anything using a raw method https://laravel.com/docs/5.5/queries#raw-expressions should bypass the cache?

Alternatively is there a way I can clear that cache or skip caching or a given query?

Environment

Laravel Version: 5.5
Laravel Model Caching Package Version: 0.2.11
PHP Version: 7.1.10
Homestead Version: N/A
Operating System & Version: OSX High Sierra

Inavalidation Problems since last version

I just updated to the latest version and now i have strange errors - maybe something todo with invalidation. (or not invalidating)

Example:
In my SalesController i prepare to add another product to the basket.
$saleItem = SaleItem::where('id','=',$request->get('id'))->first(); $product = Product::where('id',$request->get('product_id'))->first(); $saleItem->product_id = $product->id;
Now sometimes - mostly when more than one product is in the basket i get this error:
Property [id] does not exist on this collection instance. (Regarding the line $product->id)
If i disable the cache everything is ok. Before i updated to the current version everything was fine, too.

What could be the problem over here. I have the same error on different Controllers - not only regarding products.. I disabled the whole cache now - because i'm getting many errors like these...

PHP 7.1
Laravel 5.5
latest package version

Am I missing something obvious?

Issue

I have a model BannedIp - it extends CachedModel
When I delete a record using
BannedIp::where('id', 1)->delete();
The cache is not updated

Using a redis for my cache

namespace App;

use GeneaLabs\LaravelModelCaching\CachedModel;

class BannedIp extends CachedModel
{

}

It appears as if

static::deleted(function () use ($instance) {
            $instance->flushCache();
        });

in CachedModel.php is never hit

I'm trying a fresh install of laravel with a single model now to see if it's something specific to my laravel env

Environment

Laravel Version: 5.5.5
Laravel Model Caching Package Version: 0.2.10
PHP Version: 7.1.10
Homestead Version: N/A
Operating System & Version: OSX High Sierra 10.13.1

Artisan Command To Clear Specific Model Cache

Changed Question

Is there a possibility to delete only the model cache or even more specific to delete only one specific model cache? Would love to have a separate artisan command.
The reason is, that I don't like to clear all caches although I have just made on entry in one model out of 30.

Original Questions

  1. Would that reduce the amount of select queries to the db?
    Example issue just because of translations:
    laravel_queries

  2. Shouldn't that be part of Laravel standard?

  3. How can I integrate these in Vendor Models e.g. barryvdh/laravel-translation-manager#227 ?

  4. How can I delete the cache e.g. when a change was made direct on the database?

Environment

Laravel Version: 5.5
PHP Version: 7

Thank you and a happy new year.

Identical values on different whereBetween queries

Issue

$start_quarter = '2018-01-01'; $end_quarter = '2018-03-31'; $start_month = '2018-02-01'; $end_month = '2018-02-29';
Query1 ```
$sales['quarter'] = SaleItem::whereBetween('created_at', [$start_quarter, $end_quarter])
->whereIn('shop_id', $shops)
->whereIn('sku', $s_products)
->count();

Query2: ```
        $sales['month'] = SaleItem::whereBetween('created_at', [$start_month,$end_month])
            ->whereIn('shop_id', $shops)
            ->whereIn('sku', $s_products)
            ->count();

I receive identical values for both queries...
The queries are fired straight after another and the result is the same in both queries...
Can i provide a custom tag or something? If $shops or $s_products changes the result is fine, but if the one of the dates is different the result is the same...
Error: *`

Environment

Laravel Version: 5.5.34
Laravel Model Caching Package Version: 0.2.22
PHP Version: 7.1.14

Some Traits isnt working when using CachedModel

Issue

I have a model, Userwhich extends CachedModel:

class User extends CachedModel
{
}

Same model use Traits like Notifiable, Sluggable and CanFollow from package laravel-follow

class User extends CachedModel
{
    use Notifiable, Sluggable, CanFollow, CanBeFollowed, CanLike, CanFavorite, CanSubscribe, EntrustUserTrait;

    /**

The problem is that when User odel extends CachedModel, User model cant access the traits. I just realized that when i re-seeded an ongoing proyect.

>php artisan db:seed --class=LikesFollowersSeeder

In Builder.php line 2459:

  Call to undefined method Illuminate\Database\Query\Builder::subscribe()

Environment

Laravel Version: 5.5.25
Laravel Model Caching Package Version: 0.2.12
PHP Version: 7.2.0
Homestead Version: N/A
Operating System & Version: Windows 10 64bits same on Ubuntu 16.04

Dont depend on sessions for "genealabs-laravel-model-caching-is-disabled"

Issue

Some users have installations that do not use sessions as they have stateless APIs that authenticate with JWT tokens (Laravel Passport). This architecture is common and popular as it adheres to the 12 factor app principals of stateless server apps.

We therefore disable session service providers and facades as there is a significant performance increase in doing so. Along with other services.

Environment

Laravel Version: 5.5.x
Laravel Model Caching Package Version: latest
PHP Version: 7.2.x
Homestead Version: N/A - Docker (docker makes homestead development look like 1965)
Operating System & Version: Alpine Linux 3.5

Stack Trace

26) Tests\Integration\Services\JobWorkflow\WorkflowDraftToPendingTest::it_throws_exception_on_insufficient_credits
Failed asserting that exception of type "ReflectionException" matches expected exception "App\Exceptions\InsufficientCredits". Message was: "Class session does not exist" at
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Container/Container.php:752
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Container/Container.php:631
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Container/Container.php:586
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:732
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:110
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:839
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/genealabs/laravel-model-caching/src/CachedModel.php:20
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:873
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:169
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Support/Collection.php:339
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:173
/drone/src/bitbucket.org/ethical-jobs/api-app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:153
/drone/src/bitbucket.org/ethical-jobs/api-app/tests/TestFactories/OrganisationFactory.php:37
/drone/src/bitbucket.org/ethical-jobs/api-app/tests/Integration/Services/JobWorkflow/WorkflowDraftToPendingTest.php:188

Solution

In your class GeneaLabs\LaravelModelCaching\CachedModel you have a method newEloquentBuilder() that creates the builder instance. You are using a session based store to retain state regarding enabled / disabled status of the package.

As your package is based around caching one can expect a caching engine to be a requirement, the docs even suggest Redis as a best fit - with this I agree.

I believe its wrong to alos depend on the session driver for this package as another dependancy when you could simply store this session('genealabs-laravel-model-caching-is-disabled') key in the cache as well. Thus only having one external service dependancy - packages should have as few as possible to remain flexible. Also I cant see why session is being used for this over cache in the first place?

Error : Call to undefined function GeneaLabs\LaravelModelCaching\Traits\emptyArray()

Issue

I am running a test using eloquent model and during test, I am getting this error:

Error : Call to undefined function GeneaLabs\LaravelModelCaching\Traits\emptyArray()

Environment

Laravel Version: v5.5.34
Laravel Model Caching Package Version: 0.2.26
PHP Version: PHP 7.1.11 (cli) (built: Oct 25 2017 21:07:06) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Homestead Version: N/A I am using XAMPP
Operating System & Version: Windows 10 x64

Stack Trace

Testing started at 23:37 ...
C:\xampp\php\php.exe C:/xampp/htdocs/myApp/vendor/phpunit/phpunit/phpunit --no-configuration Tests\Feature\Api\V1\OrganisationApiTest C:\xampp\htdocs\myApp\tests\Feature\Api\V1\OrganisationApiTest.php --teamcity
PHPUnit 6.5.6 by Sebastian Bergmann and contributors.


Error : Call to undefined function GeneaLabs\LaravelModelCaching\Traits\emptyArray()
 C:\xampp\htdocs\myApp\vendor\genealabs\laravel-model-caching\src\Traits\Cachable.php:44
 C:\xampp\htdocs\myApp\vendor\genealabs\laravel-model-caching\src\Traits\Cachable.php:75
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:350
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:200
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php:173
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php:148
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:598
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:569
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:172
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Support\Collection.php:339
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:173
 C:\xampp\htdocs\myApp\vendor\laravel\framework\src\Illuminate\Database\Eloquent\FactoryBuilder.php:153
 C:\xampp\htdocs\myApp\tests\TestCase.php:28
 C:\xampp\htdocs\myApp\tests\TestCase.php:18
 C:\xampp\htdocs\myApp\tests\Feature\Api\V1\BaseApiTestCase.php:21
 C:\xampp\htdocs\myApp\tests\Feature\Api\V1\OrganisationApiTest.php:11
 


Time: 1.54 seconds, Memory: 14.00MB


ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Process finished with exit code 2

P.S. This works fine on version 0.2.25

Order By Rand() error

Issue

Undefined index Column

Environment

Laravel Version: 5.5.23
Laravel Model Caching Package Version: 0.2.9
PHP Version: 7.0.26
Homestead Version: none
Operating System & Version: name x.y.z

When I use orderByRaw('RAND()') in a model, I get These error. The simple solution is to test if the key exists.

Stack Trace

// vendor/genealabs/laravel-model-caching/src/CacheKey.php
protected function getOrderByClauses() : string
    {
        $orders = collect($this->query->orders);
 
        return $orders->reduce(function($carry, $order){
            return $carry . '_orderBy_' . $order['column'] . '_' . $order['direction'];
        })
        ?: '';
    }

Solution :

protected function getOrderByClauses() : string
    {
        $orders = collect($this->query->orders);

        return $orders->reduce(function($carry, $order){
            return $carry . '_orderBy_' . (isset($order['column']) ? $order['column'] : '') . '_' . (isset($order['direction']) ? $order['direction'] : '');
        })
        ?: '';
    }

Undefined index: operator

Issue

For several of my custom local scoped queries across a number of different models I am getting Undefined index: operator error. When I add disableCache() to the queries the page works again. However, these queries could really be doing with the use of cache.

The query being run at the time of error in the below stack trace is this -

    public function scopeBrandLinksForRange($query, int $brandId, string $range): int
    {
        $fromDate = Carbon::parse(explode(',', $range)[0]);
        $tillDate = Carbon::parse(explode(',', $range)[1]);

        return $query->whereBetween('created_at', [$fromDate, $tillDate])
            ->where('brand_id', $brandId)
            ->count();
    }

Environment

Laravel Version: 5.5.34
Laravel Model Caching Package Version: 0.2.22
PHP Version: 7.1.11-1+ubuntu16.04.1+deb.sury.org+1
Homestead Version: N/A (Docker Development)
Operating System & Version: Ubuntu 16:04

Stack Trace

{
    "message": "Undefined index: operator",
    "exception": "ErrorException",
    "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
    "line": 95,
    "trace": [
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
            "line": 95,
            "function": "handleError",
            "class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
            "type": "->"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
            "line": 154,
            "function": "getTypeClause",
            "class": "GeneaLabs\\LaravelModelCaching\\CacheKey",
            "type": "->"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
            "line": 114,
            "function": "getOtherClauses",
            "class": "GeneaLabs\\LaravelModelCaching\\CacheKey",
            "type": "->"
        },
        {
            "function": "GeneaLabs\\LaravelModelCaching\\{closure}",
            "class": "GeneaLabs\\LaravelModelCaching\\CacheKey",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Support/Collection.php",
            "line": 1228,
            "function": "array_reduce"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
            "line": 117,
            "function": "reduce",
            "class": "Illuminate\\Support\\Collection",
            "type": "->"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CacheKey.php",
            "line": 28,
            "function": "getWhereClauses",
            "class": "GeneaLabs\\LaravelModelCaching\\CacheKey",
            "type": "->"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/Traits/Cachable.php",
            "line": 55,
            "function": "make",
            "class": "GeneaLabs\\LaravelModelCaching\\CacheKey",
            "type": "->"
        },
        {
            "file": "/app/vendor/genealabs/laravel-model-caching/src/CachedBuilder.php",
            "line": 36,
            "function": "makeCacheKey",
            "class": "GeneaLabs\\LaravelModelCaching\\CachedBuilder",
            "type": "->"
        },
        {
            "file": "/app/app/Links/Models/Link.php",
            "line": 236,
            "function": "count",
            "class": "GeneaLabs\\LaravelModelCaching\\CachedBuilder",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php",
            "line": 953,
            "function": "scopeBrandLinksForRange",
            "class": "AdNews\\Links\\Models\\Link",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php",
            "line": 1277,
            "function": "callScope",
            "class": "Illuminate\\Database\\Eloquent\\Builder",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php",
            "line": 1470,
            "function": "__call",
            "class": "Illuminate\\Database\\Eloquent\\Builder",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php",
            "line": 1482,
            "function": "__call",
            "class": "Illuminate\\Database\\Eloquent\\Model",
            "type": "->"
        },
        {
            "file": "/app/app/Http/Controllers/Api/Analytics/LinksController.php",
            "line": 30,
            "function": "__callStatic",
            "class": "Illuminate\\Database\\Eloquent\\Model",
            "type": "::"
        },
        {
            "function": "getTotalBrandLinks",
            "class": "AdNews\\Http\\Controllers\\Api\\Analytics\\LinksController",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
            "line": 54,
            "function": "call_user_func_array"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 212,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
            "line": 169,
            "function": "runController",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 658,
            "function": "run",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 30,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
            "line": 41,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 149,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php",
            "line": 43,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 149,
            "function": "handle",
            "class": "Illuminate\\Auth\\Middleware\\Authenticate",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php",
            "line": 57,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 149,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 102,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 660,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 635,
            "function": "runRouteWithinStack",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 601,
            "function": "runRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
            "line": 590,
            "function": "dispatchToRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 176,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 30,
            "function": "Illuminate\\Foundation\\Http\\{closure}",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
            "line": 46,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 149,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php",
            "line": 28,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 149,
            "function": "handle",
            "class": "Clockwork\\Support\\Laravel\\ClockworkMiddleware",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
            "line": 53,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
            "line": 102,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 151,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
            "line": 116,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "/app/public/index.php",
            "line": 55,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        }
    ]
}

Cache doesn't invalidate when using insert method

Cache Invalidate Failed

When using insert method for multiple records the cache doesn't invalidate.
The records successfully created, but not the cache.
I'm curious is there a way to clean up the cache from the controller side, not from the command line?
since the cache doesn't invalidate well..

Thanks

Environment

Laravel Version: 5.6.5
Laravel Model Caching Package Version: 0.2.35
PHP Version: 7.2.0-1
Homestead Version: x.y
Operating System & Version: Ubuntu16.04.1

Stack Trace

        $input = [
    [
        "product_id" => 2,
    "user_id" => 51,
    "quantity" => 1,
    "information" => [
        "color" => [
        "id" => 1,
        "name" => "White",
      ],
      "size" => [
        "id" => 1,
        "name" => "S (Small)"
      ],
    ],
    "branch" => "jakarta"
  ],
  [
        "product_id" => 4,
    "user_id" => 51,
    "quantity" => 1,
    "information" => [
        "color" => [
        "id" => 2,
        "name" => "Black",
      ],
      "size" => [
        "id" => 1,
        "name" => "S (Small)",
      ]
    ],
    "branch" => "jakarta"
  ]
];
return $this->cart->insert($input);

Implement Hash Collision Prevention

Implement hash collision prevention mechanism:

  • store the key in the cache
  • comparing the stored key with the generated key after retrieving the cache instance
  • if they differ, flush the cache for that key, and recreate

error on count() or sum('column')

Issue

*Alle queries with count() or sum('columnXYZ' return a "undefined index, operator" error.
Exapmle: $sale = SaleItem::whereIn('sku', $prod_array) ->whereBetween('created_at', [$start, $end]) ->count();
*

Environment

Laravel Version: 5.5.34
Laravel Model Caching Package Version: 0.2.21
PHP Version: 7.1.0

Stack Trace

*/home/vagrant/Projects/bvj-portal-55/vendor/genealabs/laravel-model-caching/src/CacheKey.php
 
                return $carry . '_orderBy_' . $order['column'] . '_' . $order['direction'];
            })
            ?: '';
    }
 
    protected function getQueryColumns(array $columns) : string
    {
        if ($columns === ['*'] || $columns === []) {
            return '';
        }
 
        return '_' . implode('_', $columns);
    }
 
    protected function getTypeClause($where) : string
    {
        $type =in_array($where['type'], ['In', 'Null', 'NotNull'])
            ? strtolower($where['type'])
            : strtolower($where['operator']);
 
        return str_replace(' ', '_', $type);
    }
 
    protected function getValuesClause(array $where = null) : string
    {
        return is_array(array_get($where, 'values'))
            ? '_' . implode('_', $where['values'])
            : '';
    }
 
    protected function getWhereClauses(array $wheres = []) : string
    {
        return $this->getWheres($wheres)
            ->reduce(function ($carry, $where) {
                $value = $this->getNestedClauses($where);
                $value .= $this->getColumnClauses($where);
                $value .= $this->getRawClauses($where);
                $value .= $this->getOtherClauses($where, $carry);
 
Arguments
"Undefined index: operator (View: /home/vagrant/Projects/bvj-portal-55/resources/views/start.blade.php)"*

Store items for some time

Is there way to store cache not forever? As i see in code, everything is using rememberForever method.

Thank you!

Cache key namespacing pattern

Issue

They cache keys and naming scheme is quite hard for developers to read and does not follow any recognisable pattern e.g. 'genealabslaravelmodelcachingtestsfixturesbook'

Solution

It would be more readable and best practice to follow a cache key namespacing architecture as those recommended by Redis.

e.g.

genealabs:model-caching:test-fixtures:book

Pagination count query wont get cached

Environment

Laravel Version: 5.6.3
Laravel Model Caching Package Version: 0.2.33
PHP Version: 7.2.0
Homestead Version: -
Operating System & Version: macOs High Sierra 10.13.3

Stack Trace

When using the paginate query there is a count query that not get cached

$articles = Article::paginate(30);

In the debug bar you see this query:

select count(*) as aggregate from articles

Cache Doesn't invalidate

Issue

I've run Product::find(1)
and run Product::find(2)

but the result of the query is collection of product 1
the cache doesn't invalidate automatically

In my Product.php:

`
namespace App\Models;

use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Product extends Model
{
use SoftDeletes, Cachable;`

Environment

Laravel Version: 5.6.3
Laravel Model Caching Package Version: 0.2.33
PHP Version: 7.2.0
Homestead Version: x.y
Operating System & Version: Ubuntu 16.0.4

Possible Trait Conflict?

Issue

This could be my setup/env but just wanted to check

Upgraded from 0.2.28 -> 0.2.42
Getting incorrect argument 1 (array expected, string given)

Environment

Laravel Version: 5.5.36
Laravel Model Caching Package Version: 0.2.42
PHP Version: 7.1.10
Homestead Version: N/A
Operating System & Version: Centos 7

Stack Trace

Type error: Argument 1 passed to GeneaLabs\LaravelModelCaching\CachedBuilder::makeCacheKey() must be of the type array, string given, called in /Users/mattbridges/Code/test.com/vendor/genealabs/laravel-model-caching/src/CachedBuilder.php on line 30 (View: /Users/mattbridges/Code/test.com/resources/views/components/like-and-bookmarks.blade.php) (View: /Users/mattbridges/Code/test.com/resources/views/components/like-and-bookmarks.blade.php) (View: /Users/mattbridges/Code/test.com/resources/views/components/like-and-bookmarks.blade.php)

do I need to modify this to use it with jenssegers/laravel-mongodb ?

I am using jenssegers/laravel-mongodb and using hybrid relations between mysql models and mongodb models

the mongodb models however rather than extend laravel's default model, extend a special wrapper model of sorts

a lot of model-related packages on github do work out of the box with mongodb models but I'm not sure how to use this one since it depends on extending a different model

any chance you could have a quick look at jenssegers/laravel-mongodb and see if there's a quick and easy solution to using it with your package?

thanks much!

think I found a bug with where("something", "somevalue") and where("something", "<>", "somevalue")

One part of my application seems to be broken since I started using this package. I've isolated the problem now

I have a table with 300 records

$records = Place::where('place_id', $placeId)->get();

$records->count() is = 1 here

then below I run

$records = Place::where('place_id', '!=', $placeId)->get();

I tried with '<>' but that is the same as '!='

$records->count() should be 299 now, but instead it uses the cache from the above query and returns the same as the above query.. so count is 1.. and instead of getting "Every other record" it is just returning the same record

So it looks like it doesn't differentiate between the two

Why php > 7.1 requirement and not > 7.0?

Dude! This is so great!
I have created something similar myself in two different projects but this solves it in a much cleaner way. Glad to see your solutions! 😃

I wonder though, why do you force php 7.1? Why not go for the broader audience and allow also php 7.0?

Thanks again for sharing your stuff!

ID field missing

Issue

Switched from standard model to the CachedModel interface and immediately ran into a problem where I could not access the id of an entry if I had done some manual caching previously.

Environment

Laravel Version: 5.5.34
Laravel Model Caching Package Version: 0.2.21
PHP Version: 7.2
Homestead Version: N/A
Operating System & Version: Elementary OS Loki

Stack Trace

No stack trace available 

clarification of how invalidation works

I was just wondering if you could clarify how the invalidation works exactly

from the docs you said that if you don't use a cache driver that supports tags, then anytime a new model is added the entire cache will be flushed

is it then the case that if you do use a driver that supports tags.. that anytime any user adds a new model (a comment for example) then this will trigger what exactly? all cache related to comments for all users will be flushed ?

it seems it would be useful to have a way to customize our own invalidation logic.. through the configuration file

perhaps this could serve as inspiration, another excellent caching package that I use
https://github.com/spatie/laravel-responsecache/blob/master/config/responsecache.php

another question please.. you say it's a bad idea to cache users.. I agree inherently but then if the invalidation works perfectly then why not exactly?

but in any case, let's say you don't cache the user model.. what about all the relations between the user and other models? if those models extend your CacheModel then the relations will be cached but not the user ?

Clear Cache Before Every Test

It has come to light that some tests are squeaking by and passing because of existing cache entries. We have fixed this where found, but will address this as a whole, so that we can check with confidence that this doesn't occur anywhere else.

Unit tests are actually Integration tests

Issue

In the test suite there is one folder containing tests tests/Unit.

These are not unit tests as they interact with an external service integration. Thus they are tests/Integration tests because they touch either SQLite or MySQL implementation.

Solution

Rename tests folders to represent the tests they actually perform.

The lib is returning null to a attribute of Polygon type

Issue

The lib is returning null to attributes of type Polygon (Mysql). The Polygon type is saved in blob format in mysql database, and the lib is saving the blob as null (or as hex, I'm still analyzing) in redis.

Environment

Laravel Version: 5.5
Laravel Model Caching Package Version: 0.2.23
PHP Version: 7.2
Operating System & Version: Ubuntu 16.04

Doesn't consider Dates or Times in Queries ?

Issue

The cache key should consider dates and times passed within a query. For instance I am running a query like so that gets data between certain days and between certain hours of those days. Where $this represents a user model. I noticed that the cache comes back the same number of results for that user no matter the change in the query dates. Is this normal behavior or have I done something wrong on my end?

I am going to look into the laravel-model-caching package now.

Environment

Laravel Version: 5.6.3
Laravel Model Caching Package Version: ^0.2.22
PHP Version: 7.1.12
Homestead Version: N/A
Operating System & Version: Mac OS X High Sierra 10.13.3

Stack Trace

$this->commissioned()
         ->whereDate( 'created_at', '>=', $start_date )
         ->whereDate( 'created_at', '<=', $end_date   )
         ->whereTime( 'created_at', '>=', $start_time )
         ->whereTime( 'created_at', '<=', $end_time   )
         ->paid()
         ->outbound()
         ->get();

flush all cache through artisan, and typo

php artisan modelCaching:flush --model=App\Model

should be

php artisan modelCache:flush --model=App\Model

And I noticed that you HAVE to specify a model.. it would be very preferable to being able to flush all of the modelCache.. without having to flush the entire redis cache

could this be added please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.