laravel - Is there a way to "Eager Load" entire models from (cached) files, so database not is asked and yet t

I work with Laravel 12 in a browser based game evironment with a lot of tables just containing basicst

I work with Laravel 12 in a browser based game evironment with a lot of tables just containing basic/static data. Most of the time that is pretty convenient as you can do lots of game design changes and test stuff without changing code like big arrays.

On the other hand, there are lots of calls to those tables, all of which are pretty small, yet stress the database and in the end the bottleneck is I/O.

An example: There is

  • Models\Avatar
  • Models\AvatarItem (AvatarId, ItemId)
  • Models\Item
  • Models\ItemSocket (ItemId, SocketId)
  • Models\Socket

As you can imagine, there are Avatars having Items and those can have some Sockets. Now as you grow a userbase, all tables get more data, yet sockets stay the same. This table just holds basic data (e.g. 50 rows) of all known sockets there are. In my POV there is absolutely no need to select/join those over and over again, even if those selects are pretty fast, as MySQL holds them in memory and eager loading helps too. And there are quite a few of those basic data tables (not just Sockets).

I am looking for a sort of export of this Model export(Socket::all()) so I can later virtually import the cached data and Laravel does not see a difference. Maybe something like a VirtualModel that does return Socket::make($stuff) but 50 times and in a structure that works with relations the same as fetched/eager loaded.

Is there anything like this static "import" approach, to get rid of joins to tables without changes?

I tried caching too, yet find it hard make the Avatar::with([*100 links*]) work with cached results without losing the convenient coding style.

Cheers

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744115372a4559148.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信