Skip to content

first (cached) result is always returned for other (subsequent) queries for the same model #100

Closed
@hxnk

Description

@hxnk

It seems that when performing a second (different) query for a Model, the (cached) result of the previous query is always returned...

Steps to reproduce

  1. Clean install of Laravel 5.6.9 and package version 0.2.47
  2. Have 3 instances of a model (e.g.: App\Car) stored in the database
  3. Call App\Car::all()
  4. Call App\Car::first()

Result

  • Result of step 3: Collection of 3 Car models
  • Result of step 4: cached result of step 2 is returned (thus giving a collection with 3 Cars, instead of a single Car Model)

The same happens when doing something like:

  1. Call App\Car::where('id', '<', 100)->get()
  2. Call App\Car::where('id', '<', 100)->first()

or

  1. $car = new App\Car
  2. $car->all()
  3. $car->first()

Results are the same for Cache drivers "redis" and "file"
I did not change any other configuration, just added the Cachable trait to the Model

Maybe I'm missing something obvious, since this seems to be quite a big issue, but I haven't seen any one else report it...

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions