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条)