Answer the question
In order to leave comments, you need to log in
Implement global data caching in Yii2?
I plan to rewrite the project from PhalconPHP to Yii2. Without going into details, why I'm changing the framework, I'll ask this:
How can Yii2 implement global entity caching?
Explanation:
Take the entity User . The User has a Skin avatar . They are connected. Skin has an uploader, i.e. the one who uploaded it and, oddly enough, is User . After that, we have more complex entities: Comment and Post (in fact, there are more of them). Comment contains the author, and for output to the frontend (or response via API), we always need Skin as well, because how can we do without an avatar. EssencePost has the same author and all the same data is needed for normal operation. From this it turns out that for the selection of posts will always be used . And this means that we will constantly have the following requests:Post::find()->with('author', 'author.skin')->all()
SELECT * FROM posts
SELECT * FROM users WHERE id IN (...)
SELECT * FROM skins WHERE id IN (...)
Answer the question
In order to leave comments, you need to log in
1. There is cache tagging. See yii\caching\TagDependency.
2. Look at www.yiiframework.com/doc-2.0/guide-db-active-recor...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question