Override cache remember method

Posted 3 months ago by sobhan93

I would like to override the method remember() of the class Illuminate\Cache\Repository as :

<?php
namespace App\Illuminate\Cache;

use Illuminate\Cache\Repository as BaseRepository;

class Repository extends BaseRepository{

    public function remember($key, $minutes, Closure $callback)
    {
        // changes
    }
}

But I don't know how to tell Laravel to load my class instead of the original one.

<?php

use Illuminate\Support\Facades\Cache;

Cache::remember("key", 1, function () {
    return "hello world!";
});

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.