PHP code example of pulkitjalan / cacheable

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

    

pulkitjalan / cacheable example snippets


PulkitJalan\Cache\Providers\MultiCacheServiceProvider::class



namespace App;

use Illuminate\Database\Eloquent\Model;
use PulkitJalan\Cacheable\Cacheable;

class CachedModel extends Model
{
    use Cacheable;
}



namespace App;

use Illuminate\Database\Eloquent\Model;
use PulkitJalan\Cacheable\Cacheable;

class CachedModel extends Model
{
    use Cacheable;

    /**
     * Set the cache expiry time.
     *
     * @var int
     */
    public $cacheExpiry = 60;
}

// cached
CachedModel::find(1);

// not cached
CachedModel::where('some_field', 1)->find(1);

// not cached
CachedModel::with('relation')->find(1);

// manually clear cache
CachedModel::find(1)->refresh();