Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Observers;
- use App\Product;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\DB;
- class CacheProduct
- {
- public function created()
- {
- Cache::forget('products');
- Cache::remember('products', 60, function() {
- return DB::table('products')->get();
- });
- \Log::info('Cache atualizado');
- }
- public function deleting(Product $product)
- {
- Cache::forget('products');
- Cache::remember('products', 60, function() {
- return DB::table('products')->get();
- });
- \Log::info('Cache atualizado');
- }
- }
Add Comment
Please, Sign In to add comment