Most Minteresting

Let’s get right to it- I’ve been blogging a lot about Mint lately, and there really is a good reason for it all. As a PHP/MySQL person, I love to tinker. You may have noticed a new thing where the portfolio used to be (if you’re not the type for RSS). Thanks to Shaun’s Mint and the good plugin folks of Textpattern, I’ve written up a little something I like to refer to as the “Most Mintersting Articles”. Puns and jokes aside, this is a pretty robust plugin for TXP, and includes its own caching module.

The need was a simple enough one, I wanted more exposure for the more interesting things on the site I’ve written. Some articles get a lot more reads than others, and some articles get a lot more comments. Since Mint is really good at collecting where on my site people went, it made sense to design a plugin to focus on that aspect. Additionally, Mint rolls its data and deletes old logs so the “freshest” pages are always going to update with time.

Caching the Minty Joy

If I could walk out of here with a LIKE % in my SQL and run it every single time no matter what, I would have. However, that’s a bad idea on a small machine with a big database table. With a little bit of caching, we can eliminate the server strain that would otherwise be caused by the plugin. (And if it’s really extreme, removing the wild-cards from the resource variable can remove the problem altogether.) The caching concept is actually based on a very old method we used for Gaia Online, put together with a bit more modern piece from the new database code we rolled out. It is based on the idea that if a query should be cached, it’s SQL should never change. This means we can base the filename for the cache off of the SQL query. Since we have a very small number (1) of queries in this case, a CRC32 will suffice.

The Goods

The rest really just needs to be seen to be believed. Of course, you need Mint (link at the top there) to make use of this, but Shaun made some awesome software, so it’s well worth the price. I’d like to think of this as another good reason to get fresh and minty!

Update: Version 0.2 now supports the Mint object if Mint is on a different database than TXP.

Download minteresting v 0.2 available as a gist

Webmentions
What’s this?

Tweets, mentions, and trackbacksShare your thoughts

As this gets discussed, comments will show up here. If the post is new, it may take a bit for your thoughts to get from one side of the internet to the other.

Code Drift is the personal website of Rudolph Jakob Heuser