Answer the question
In order to leave comments, you need to log in
Best way to store temporary search results obtained via VK API (in Yii2)?
Good day!
I am developing a small application for searching and getting a list of users by certain parameters using the VK API and the Yii2 framework. But with a large number of users, the initial script loading time is quite considerable. And given that pagination will also be used to display the results, then by itself this long search process will be repeated on each page.
The search can be performed by a large number of users.
What method of storing temporary data is the most preferable in this situation (given the use of Yii2)?
Thanks in advance for your reply!
Answer the question
In order to leave comments, you need to log in
you are most likely using arrayprovider there.
When I wrote the API for plati . ru, drove the entire selection into the cache. and took it from there.
In general, it is correct to use the cache methodology for storing results. And the specific implementation may be different.
1) Simple and fast: this is a file cache, for this Yii2 has the yii\caching\FileCache component. If you have a fast SSD disk in use, then this will be enough for a thousand read requests per second. But here you can run into a record - if there are a large number of simultaneous changes in the cache (for example, more than a few tens per second). With all this, for small projects, the file cache on the SSD will work many times faster than specialized systems - due to the absence of unnecessary overhead for the functioning of the caching system itself.
2) Complicated (conditionally), fast, scalable: for example, using Redis, for this Yii2 has a componenthttps://github.com/yiisoft/yii2-redis. The data is stored in RAM, so it should be with a margin, specific atomic actions with the cache will be slower than with the file cache on the SSD, but due to the architecture and the ability to scale the system, it can withstand very high read and write loads. And also in Redis, the gain will be when the amount of data itself starts to increase - for example, more than a million records - this will happen due to the use of a fast index to search for identifiers. The interfaces are quite simple, but you still need to understand how everything works and spend some time on it - quite often I encounter the incorrect use of Redis in projects.
PS
"a large number of users" is a relative concept - it is better to indicate the possible average or the required "ceiling".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question