[wp-hackers] Examples of plugins that use the transient API

Otto otto at ottodestruct.com
Thu Aug 5 17:05:04 UTC 2010


Or, if you really just want a plugin, I use transients in Simple
Twitter Connect.

STC is a complicated plugin, but the simplest example is in the STC -
Followers Widget. Basically, it displays a list of my followers on
twitter along with their pictures and so forth. I have it displaying
12 random followers on my sidebar at ottopress.com.

To do that, the plugin has to make a request to
http://api.twitter.com/1/followers/ids . This returns a rather large
list of up to 5000 followers, which I store in a transient because the
request is annoyingly large and I don't want to upset Twitter by
requesting it all the time. The cache is timed for 24 hours.

Anyway, it then takes those 5000 followers, randomizes them, grabs 100
of them, and does a request for their more detailed information from
Twitter using http://api.twitter.com/1/users/lookup (which allows up
to 100 users per request on this case). That information is then
cached in a transient as well. Eventually, 12 random of them are
selected and their info displayed in the box. These 12 randoms are
changed every page load, but since that information is cached, it's
only two requests to Twitter's servers, max, every 24 hours.

-Otto


On Thu, Aug 5, 2010 at 11:48 AM, Chris Olbekson <chris at c3mdigital.com> wrote:
> Hello All,
> I will be speaking at WordCamp Houston this weekend on performance and I
> would like to show some examples of plugins and or themes that
> make efficient use of the Transient API.  If anyone could point some out to
> me I would greatly appreciate it.  I am going to be demonstrating how
> Memcached improves performance by storing transient data in ram.
>
> --Chris Olbekson
>
>  [image: WordPress Support Profile]
> <http://wordpress.org/support/profile/3629249>
>
> <http://wordpress.org/support/profile/3629249>
>
> [image: C3MDigital.com] <http://c3mdigital.com>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list