I have this query:
$begin = $startDate->format('Y-m-d');
$end = $endDate->format('Y-m-d');
$model = $this->model;
$days = \Cache::remember('query:get_sales:' . $userId . ':' . $begin . ':' . $end, 5,
function() use($model, $begin, $end) {
return $model->select([
\DB::raw('DATE(`created_at`) as `date`'),
\DB::raw('SUM(amount) as `total`')
])
->where('created_at', '>=', $begin)
->where('created_at', '<=', $end)
->groupBy('date')
->orderBy('date', 'DESC')
->lists('total', 'date');
});
As you can see I cache it, but I also want to flush the index query:get_sales:$userId:*. The * means I want to flush every cache that it's key begins with this string.
How can I do that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire