PHP code example of quietasice / rememberable

1. Go to this page and download the library: Download quietasice/rememberable 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/ */

    

quietasice / rememberable example snippets


// Get a the first user's posts and remember them for a day.
User::first()->remember(1440)->posts()->get();


namespace App;

use Watson\Rememberable\Rememberable;
use Illuminate\Database\Eloquent\Model as Eloquent;

abstract class Model extends Eloquent
{
    use Rememberable;
}


namespace App;

class Post extends Model
{
    //
}

// Remember the number of users for an hour.
$users = User::remember(60)->count();

// Remember the number of users for an hour and tag it with 'user_queries'
User::remember(60)->cacheTags('user_queries')->count();

// Remember the number of users for an hour and prefix the key with 'users'
User::remember(60)->prefix('users')->count();

// Remember the number of users for an hour using redis as cache driver
User::remember(60)->cacheDriver('redis')->count();

$users = User::where("id", ">", "1")
    ->with(['posts' => function ($q) { $q->remember(10); }])
    ->remember(10)
    ->take(5)
    ->get();

User::flushCache('user_queries');

User::flushCache();

User::latest()->dontRemember()->get();