Juniorsz/easy-repository

View on GitHub
src/Repositories/Cacheable/CacheableRepository.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace VyDev\Repositories\Cacheable;

use Illuminate\Support\Facades\Cache;

class CacheableRepository
{
    private $data;
    private $cacheKey = null;

    public function __construct($data, $cacheKey)
    {
        $this->data = $data;
        $this->cacheKey = $cacheKey;
    }

    public function remember()
    {
        return Cache::remember($this->cacheKey, 100, function () {
            return $this->data;
        });;
    }
}