PHP code example of darkghosthunter / rememberable-query

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

    

darkghosthunter / rememberable-query example snippets


Articles::latest('published_at')->take(10)->remember()->get();

use Illuminate\Support\Facades\DB;
use App\Models\Article;

$database = DB::table('articles')->latest('published_at')->take(10)->remember()->get();

$eloquent = Article::latest('published_at')->take(10)->remember()->get();

DB::table('articles')->latest('published_at')->take(10)->remember(60 * 60)->get();

Article::latest('published_at')->take(10)->remember(now()->addHour())->get();

Article::latest('published_at')->take(10)->remember(30, 'query|latest_articles')->get();

Article::latest('published_at')->take(10)->remember(store: 'redis')->get();

Article::latest('published_at')->take(200)->remember(wait: 5)->get();

$key = auth()->user()->getAuthIdentifier();

Article::whereKey(54)->remember(now()->addHour(), "query|user:$key")->increment('unique_views');

User::whereName('Joe')->whereAge(20)->remember()->first();
// Cache key: "query|/XreUO1yaZ4BzH2W6LtBSA=="

User::whereAge(20)->whereName('Joe')->remember()->first();
// Cache key: "query|muDJevbVppCsTFcdeZBxsA=="

User::whereName('Joe')->whereAge(20)->remember(60, 'query|find_joe')->first();
User::whereAge(20)->whereName('Joe')->remember(60, 'query|find_joe')->first();

$joe = Cache::get('query|find_joe');