PHP code example of adamcrampton / object-cache

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

    

adamcrampton / object-cache example snippets

 artisan vendor:publish
$this->objects
app/Http/Kernel.php
config/app.php
app/Http/Kernel.php
$this->objects
$this->objects
namespace App\ObjectCache;

use App\Models\PartPrice;
use AdamCrampton\ObjectCache\ObjectCache;

class CacheMethodStore
{
    public $objects;
    
    public function __construct()
    {   
        $this->objectCache = new ObjectCache();
        
        $this->objects = [
            [
                'cacheKey' => 'exampleKey',
                'cacheTtl' => $this->objectCache->ttl['hours']['twentyFour'],
                'cacheMethod' => 'setExample'
            ]
        ];
    }

    public function setExample()
    {
        return PartPrice::select(['part_id', 'price'])
            ->get()
            ->toJson();
    }
}

    /**
     * Fetch part data for the front end.
     *
     * @return array
     */
    protected function buildPartData(Request $request)
    {
        return ObjectCache::get('dealer_123456_part_data', 'array');
    }