Everybody Staze...

Nobody leavz...

  • Home
  • About Me
    • LinkedIn
    • Lab
  • Contact
  • Links
  • Reviews
  • Sitemap
  • Weather

WordPress _transient buildup

2011/05/03 By staze

WordPress uses DB entries called _transients to cache certain data. Cached entries are by default, things like RSS info, when cron last run, etc. If you use a plugin like Google Analytics Dashboard (GAD hereafter) though, you also get cached data relating to that. Unfortunately, either due to a bug in WordPress, or something left out of GAD, this cached info doesn’t seem to be deleted after it’s designated expiration time/date (_transients have a set expiration time, but they don’t seem to matter for GAD set transients).

Looking around online, I found someone who was dealing with a similar problem here.

The trick was to add the following to my the functions.php file in my theme.


add_action( ‘wp_scheduled_delete’, ‘delete_expired_db_transients’ );

function delete_expired_db_transients() {

global $wpdb, $_wp_using_ext_object_cache;

if( $_wp_using_ext_object_cache )
return;

$time = isset ( $_SERVER[‘REQUEST_TIME’] ) ? (int)$_SERVER[‘REQUEST_TIME’] : time() ;
$expired = $wpdb->get_col( “SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE ‘_transient_timeout%’ AND option_value < {$time};" ); foreach( $expired as $transient ) { $key = str_replace('_transient_timeout_', '', $transient); delete_transient($key); } }

Later in the day, when that cron task ran, it removed all the expired transients from my wp-options table, and at midnight, when my system cron task ran to optimize my DB tables, the table shrunk down to the size it should be. If you so wanted, you could add the optimize operation to the above, but I figure it’s not that big of a deal once things are under control. As always, back up your DB and any files you modify before implementing changes. If you have access to a mysql console, you can also try the query out by doing something like:

SELECT option_name FROM wp_options WHERE option_name LIKE '_transient_timeout%' AND option_value < now();

You'll want to change "wp_options" if you have a different prefix set for wordpress. Theoretically, that query should show you all your expired transients.

Have fun!

Filed Under: Coding Tagged With: GAD, transient, Wordpress

404’s and sitemaps

2011/04/24 By staze

Just did a bit of a tweak to my site to address something that I always thought sucked, but never really looked into: 404s.

404s traditionally are ugly, and unhelpful. They say “can’t find what you’re looking for” and that’s about it. With the advances since PHP and CMS’s have come about, this doesn’t have to be the case. So, I’ve replaced my previously stock, and ugly, 404 page with the wonderful 404 info from Yoast, as well as implemented an HTML sitemap as per his other post here. The only other thing I did was modify the 404 page a bit so that if someone tries to look for a file on my site that’s a PNG, GIF, JPG, JS, etc, they get a basic “file not found”. This code came from here.

It’s all pretty boring, but I think it’ll make the user experience of my site a bit more friendly. And it’s more inline with Google’s current thoughts about 404 pages.

Filed Under: Miscellany Tagged With: wordpress 404 yoast binarymoon

Toro Ultra Blower Vac (51599)

2011/04/23 By staze

Unfortunately, my neighbors have several large Douglas Fir trees that extend out over my driveway and thoroughly cover my driveway in needles every few weeks. Since I’ve bought the house, my fix for this was to borrow a pressure washer from someone, and wash the needles/moss off every 6-10 months. This took the better part of a day, but resulted in a pretty clean, yet more damaged, driveway (the driveway is original to the house (1978) and started out as a rather rough texture even then). One thing pressure washing DID do was remove the moss that grows on my driveway since it’s such a rough texture, and the aforementioned Douglas Fir’s keep it from getting much direct sunlight. But all and all, pressure washing to remove needles is a bit overkill. Enter, the leaf blower.

I’ll start by saying my wife was skeptical that a blower would be able to take care of the needles. But having read the Consumer Reports article on the blower vac, I was pretty confident it would work. After bringing it home, I fired it up and was immediately rewarded with needles, fir cones, twigs, and small rocks flying everywhere. I blew all the needles and everything off the driveway in less than 15 minutes, and in the end, I wasn’t covered in dirt and water. While it didn’t do anything to rid the driveway of moss, it did make the moss much more visible, and will probably aid in removal via pressure washing later (since I won’t have to deal with the fir needles as well as the moss).

I’ve since blown off the driveway again (a week later), and this time it went by very fast (5 minutes). I figure once a month will take about 10 minutes, and I should be able to greatly reduce the amount of needles tracked into my garage by the car, and into the house by people.

I haven’t tested the leaf vacuum aspect yet, but if it works half as well as the blower, I’ll be quite happy.

[xrr rating=4.75/5]

Filed Under: Reviews Tagged With: Leaf Blower, Leaf Vacuum, Toro

« Previous Page
Next Page »

Weather

Categories / Archives

  • Apple
  • Coding
  • Electronics
  • Energy
  • Home Ownership
  • Miscellany
  • Politics
  • Prius
  • Sys Admin
  • Travel
  • Uncategorized
  • Work
  • June 2026
  • April 2026
  • August 2025
  • April 2025
  • January 2024
  • February 2021
  • July 2020
  • January 2020
  • April 2019
  • March 2018
  • February 2018
  • June 2017

Copyright © 2026 · Staze On Genesis Framework · WordPress · Log in