Comments (7)
What if you use
protected $touches = ['Product'];
on Country Model can you confirm
I want to use the in one of my project
from laravel-model-caching.
@geniqtech the key question is how you are making changes to the table. If you make the changes via Eloquent queries, the cache should be invalidated. If you make changes to the table data directly, the cache has no way of knowing you made updates.
from laravel-model-caching.
@mikebronner We are making changes via Eloquent queries. Referring to the example in my use case above, if we make changes to countries table via Eloquent queries, the cached item is not invalidated.
from laravel-model-caching.
@KimpShreyan AFAIK "$touches" only updates the "updated_at" column and is meant for a different purpose.
from laravel-model-caching.
@geniqtech Could you provide the query you are using to make changes?
from laravel-model-caching.
Here's the code snippet:
// Check before update
$data = Country::select('countries.*', 'products.name AS product_name')
->leftJoin('products', 'products.country_code', 'countries.country_code')->get();
Log::info($data);
// Update Product
$product = Product::find(1);
$product->name = 'banana';
$product->save();
// Check again after update
$data = Country::select('countries.*', 'products.name AS product_name')
->leftJoin('products', 'products.country_code', 'countries.country_code')->get();
Log::info($data);
Logs Output
local.INFO: [{"country_code":"US","name":"United States","product_name":"apple"},{"country_code":"JP","name":"Japan 1","product_name":"orange"}]
local.INFO: [{"country_code":"US","name":"United States","product_name":"apple"},{"country_code":"JP","name":"Japan 1","product_name":"orange"}]
from laravel-model-caching.
Hello guys!
Any updates in this?
I'm also having some issues with join, seems to not be invalidating cache correctly, is it supported ?
This is how I'm populating the database:
PostComment::create([
'comment' => $message,
'post_id' => $taskId,
'created_by' => $user->id
]);
How i'm querying:
$postComments = Post::select(
'user.id',
'user.uuid',
'user.name',
'post_comments.created_at',
'post_comments.comment'
)->join(
'post_comments',
'post_comments.task_id',
'posts.id'
)->join(
'users',
'user.id',
'post_comments.created_by'
)->where('posts.uuid', $uuid)->orderBy('post_comments.created_at', 'desc');
This query doesn't show any updated results.
But, if I change to this:
$postComments = PostComments::select(
'user.id',
'user.uuid',
'user.name',
'post_comments.created_at',
'post_comments.comment'
)->join(
'posts',
'posts.id',
'post_comments.task_id'
)->join(
'user',
'user.id',
'post_comments.created_by'
)->where('posts.uuid', $uuid)->orderBy('post_comments.created_at', 'desc');
it works, but before I updating my laravel-model-caching the first query was working properly if I'm not wrong.
from laravel-model-caching.
Related Issues (20)
- What is cacheCooldownSecounds definition? HOT 1
- Add support for Laravel 10 HOT 2
- Object of class Illuminate\\Database\\Query\\Expression could not be converted to string HOT 6
- Since 0.12.4 I get error "GeneaLabs\LaravelModelCaching\CacheKey::processEnum(): Argument #1 ($value) must be of type BackedEnum|UnitEnum|string, null given, called in ...\vendor\genealabs\laravel-model-caching\src\CacheKey.php on line 409" HOT 23
- Cannot access "parent" when current class scope has no parent HOT 1
- Laravel v10.3.0 breaks LaravelModelCaching HOT 2
- checkCooldownAndFlushAfterPersisting(): Argument #2 ($relationship) must be of type string, array given, called in /var/www/html/vendor/genealabs/laravel-model-caching/src/Traits/ModelCaching.php on line 83 HOT 8
- The attribute [column3] either does not exist or was not retrieved for model HOT 1
- Stale cached value returned where(...)->first() HOT 4
- Fix for GeneaLabs\LaravelModelCaching\CacheKey::processEnum(): Argument #1 ($value) must be of type BackedEnum|UnitEnum|string, null given
- processEnum(): Argument #1 ($value) must be of type BackedEnum|UnitEnum|Illuminate\Database\Query\Expression|string, null given HOT 2
- Conflict with Spatie Schemaless
- Laravel 11 upgrade blocked by laravel-pivot-events dependency HOT 1
- Missing import in CachedBuilder?
- Fix failing tests HOT 1
- Uuid fromBytes throwing a error HOT 1
- Observer for Pivot Model not firing HOT 3
- Bug: CacheKey::getValuesFromBindings(): Return value must be of type string, null returned | when where value is null HOT 1
- Object of class Illuminate\Database\Query\Expression could not be converted to string
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-model-caching.