Level 122
Put the items inside an array. You can load it as one entity, add or remove from it and write it back to cache?
I want to track user activity with this controller:
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$user = auth('api')->id();
if ($user) {
Cache::put('last_active.' . $user, now());
}
}
}
Then on a schedule running every 10 minutes, find all Cache items matching last_active.*, then update the User's last_active column.
I initially reached for Cache tags, but they are no longer documented or recommended. What should I do instead?
Please or to participate in this conversation.