m-a-k-o / nova-custom-table-card

Simple Nova Card for Custom Tables
MIT License
46 stars 26 forks source link

[request] Add caching method #2

Open abordage opened 6 years ago

abordage commented 6 years ago

Hi. Thanks for the package. Do you plan to add a caching method?

Like here: https://nova.laravel.com/docs/1.0/metrics/defining-metrics.html#caching

m-a-k-o commented 6 years ago

Hi. I'm happy that you are using my package.

I will check the possibilities and update the status asap.

nasyrov commented 4 years ago

Hi @m-a-k-o ,

I think this one could be closed, caching could be added easily like so:

$users = Cache::remember('users', 60, function () {
    return DB::table('users')->get();
});

$this->data($users->map(...));
m-a-k-o commented 4 years ago

@nasyrov Indeed, keeping it open for implementation of nova standard cache method.

nasyrov commented 4 years ago

Although I've spotted one issue, if you register a custom card on dashboard and query database in __construct method, your query will be executed on every request to Nova.