B
B
BonBon Slick2017-10-04 12:56:10
caching
BonBon Slick, 2017-10-04 12:56:10

Should I use an extra layer of abstraction through Repositories in Laravel?

Is it worth it to install this package https://github.com/andersao/l5-repository , as I understand it, the repository improves performance because they additionally cache data before fetching and inserting it into the database, it also caches queries, right?
And if Redis is already worth it?
Do I need to install repositories early when the load is zero?
Are there any other reasons for putting them on?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Eugene Wolf, 2017-10-04
@BonBonSlick

And if Redis is already worth it?
Depends on what exactly Redis does in your case.
Do I need to install repositories early when the load is zero?
There is a golden rule, it sounds like "If it's not broken - don't fix it", why would you complicate the code if everything works anyway?
Are there any other reasons for putting them on?
I have never set it, the flight is normal. Even on well-loaded projects. (Are we discussing load here?)
as I understand it, the repository improves performance because they additionally cache data before fetching and inserting it into the database
In general, in the description of the package, I see that they give "more flexibility" (according to the author), I have not yet found about "more speed" in the text (maybe I was looking badly). How to cache data before fetching - I can imagine, but how you can cache data before inserting it (or why do it at all?) - it seems vague to me. And by the way, MySQL itself caches the results of queries, at the level of the database itself, or are you talking about some other cache? Or you don't have MySQL?
And, one more thing... You can (need) to cache not everything and not always, even if you really want to. Since in some cases the cost of building a cache can "cost more" than its final performance.

N
Nikolai Kokoulin, 2017-10-04
@Kokoulin

Using repositories is a good practice, I see no reason not to do them

V
Vyacheslav Plisko, 2017-10-04
@AmdY

This package is not at all the repository that everyone thinks about looking at the name. In fact, he repeats Eloquent and is tied to his device. A very dubious thing. And Laravel itself can cache out of the box without left packages.

H
hOtRush, 2017-10-04
@hOtRush

There are cases when repositories come in handy - when there is too much logic in the controllers, but in the remaining 90% of cases it is an overhead

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question