Hello,
I have a page on my website with about a 1000 records that barely change, like a blog. I would like to cache this. The thing is, users can filter and sort these records. A quick calculating thought me that there are 10.000 different filtered sets.
So there are 10.000 different ways to filter and order about 1000 records.
Question 1
Right now I'm thinking about creating a hash of the filterset and use that as part of the cachekey to cache all these items.
Is this the way to go? Or do you have other experiences/solutions to this problem?
Question 2
There's also the problem of pagination. I might have up to 10.000 different keys (shouldn't be a problem for redis) still, I do prefer storing the whole 1000 results unpaginated and then paginate the collection after retrieving everything from cache.
Is that okay, or again: is there a different approach I might consider? Quick sight question: how does Redis handle storing 1000 (pretty big) eloquent models in one kay/value pair? Should be fine?
Question 3
Also, people can search in very specific fields of my models. I intend to not cache search queries (just too many different options, users can type in anything), but instead fetch the results and perform a search on that (right before pagination, see questions 2). Everybody okay with that? :p
Question 4
Performing all the queries takes about a second, even after optimizing them. I think that's too long (keep in mind the whole page load is even longer!). Now this is mostly just the first time, after that, results are cached. Still, I would like to build the cache before the user gets there.
Thing is, saving 1 model, possible effects all 10.000 different sorting and filtering options. Any tips/best practices on this?
Any input and experiences from others is very welcome :)