tetherless-world / s2s

Tetherless World S2S Faceted/Hierarchical Browser
GNU General Public License v2.0
1 stars 0 forks source link

PHP APCu caching #24

Open zednis opened 9 years ago

mrpatrickwest commented 9 years ago

Sounds like we're caching the html that would be displayed for the given result. That way, for example, in the publication browser we don't have to do that additional query to get the author list and we can just display the html that we get from the cache.

mrpatrickwest commented 9 years ago

what if we changed the query to only return the uris of the result. So the first time the publication browser runs we grab the first ten publication uris, check the cache to see if the html exists and if not run the queries to generate the html then store the html based on the uri?

zednis commented 9 years ago

We could do that. I am not sure how much performance improvement there would be over the current caching location. In cache-hit situations it would mean the preliminary query before the cache check would be simpler so there may be some improvement there.

mrpatrickwest commented 9 years ago

Oh I see what's going on. You're taking the arguments to the getResponse call and creating a key from them. This is even before a query is run. So bypassing the query all together if the arguments are cached. And what's stored is the generated html for that result set.

zednis commented 9 years ago

Right, I believe $results is build from a pretty simple and small query - return basic info for each result record and include query constraints in the where clause. I believe some simple properties such as label and publication year are included in the $results and could be moved to a second query that is cached.

mrpatrickwest commented 9 years ago

agree with your comment. The thing with the publication browser is that yet another query is run for each URI in the result set. What I was thinking of doing is running a very simple query at first, just grab the URI. Cache information for that URI and use that to generate the html. So even if the constraints change, the offset changes, or for whatever reason APCu doesn't have the full result cached, we could have individual URI properties cached.

mrpatrickwest commented 9 years ago

Would be nice too to be able to pre-populate the cache somehow. A script that runs the queries without constraints and goes gets each page of results. I imagine it would have to be run within apache.