Why not get the data from the cache?

There is a API written in lumens. Request heaps of orders generates a large amount of data (in the process of assembling the resource pulled a bunch of data, including raw queries to the database). It was decided that each order (order) cache, and the cache driver was chosen radish.

$orderids do = $request->list;

// Get the order from the cache
$cachedOrders = Cache::tags($orderids do)->get('orders-resource') ?? [];

// Looking for ajtishniki, which was not in the cache
$nonCachedIds = count($cachedOrders) === 0 ? $orderids do : $cachedOrders->whereNotIn('id', $orderids do);

// Get from the database is cached order
$fromDbOrders = Order::withTrashed()->with('comments')->findMany($nonCachedIds);

foreach ($fromDbOrders as $order) {
 $orderResourced = OrderResource::make($order)->toArray($request);
 $cachedOrders[] = $orderResourced;
Cache::tags($order->id)->put(
"orders-resource",
$orderResourced,
 Carbon::SECONDS_PER_MINUTE * 10000
);
}

return response()->json(new Report(
"200",
$cachedOrders,
 "The list of orders to the database",
$requestId
));


The radishes I see them, but on the next request, trying to get the cached order using dd($cachedOrders); get empty. Maybe I do not understand the concept of tags ? without them it would be difficult to do, because one order will be attached a few caches and will need to clean all that is connected with specific order.
March 23rd 20 at 19:46
1 answer
March 23rd 20 at 19:48
Solution
The tags for such applications unusable. Only use for cleaning the cache by tags.

Find more questions by tags LaravelRedis