PHP code example of singlequote / laravel-cacher

1. Go to this page and download the library: Download singlequote/laravel-cacher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

singlequote / laravel-cacher example snippets


namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable; //<= basic shizzle
use Illuminate\Contracts\Auth\MustVerifyEmail; //<= basic shizzle

use SingleQuote\Cacher\Traits\Cacher; //⇐ this one

class User extends Authenticatable implements MustVerifyEmail
{
    use Cacher; //<=  

use App\User;

$users = User::whereEmail('[email protected]')->remember(); //<= default ttl is 7 days
$users = User::whereEmail('[email protected]')->remember(3600); //<= 1 hour

//or keep it forever by your side <3
$users = User::whereEmail('[email protected]')->rememberForever();

    $users = User::whereEmail('[email protected]')->prefix("all-users")->remember(); //prefix all-users
    
    cache()->forget("all-users");

    $users = User::whereEmail('[email protected]')->remember(/*3600*/); //for 1 hour -  default 7 days
    $users = User::whereEmail('[email protected]')->rememberForever(); //for ever
    
    //find
    $user = User::whereEmail('[email protected]')->findAndRemember(1, /*3600*/);
    $user = User::whereEmail('[email protected]')->findAndRememberForever(1);
    
    //first
    $user = User::whereEmail('[email protected]')->firstAndRemember(/*3600*/);
    $user = User::whereEmail('[email protected]')->firstAndRememberForever();
    
    //counting
    $user = User::whereEmail('[email protected]')->rememberCount(/*3600*/);
    $user = User::whereEmail('[email protected]')->rememberCountForever();
    
    //paginating
    $user = User::whereEmail('[email protected]')->paginateAndRemember(20, /*3600*/); //return 20 results
    $user = User::whereEmail('[email protected]')->paginateAndRememberForever(20); //return 20 results