[wp-hackers] Transient key best practice

Nikola Nikolov nikolov.tmw at gmail.com
Mon Sep 9 19:54:19 UTC 2013

Additionally, if you want to be able to get all transients created by your
plugin(for whatever reasons you might have), you can simply prefix the
md5-ed hash with something(like "nsyt_{$md5_hash}").

If you wouldn't need to get all of your plugin's transients, you can
most-likely drop the namespace, although it can never hurt - md5() is 1)
fast, 2) the hash is always the same length. So 10 characters more or less
doesn't make a huge impact IMO.

On Mon, Sep 9, 2013 at 10:50 PM, Micky Hulse <mickyhulse.lists at gmail.com>wrote:

> Thanks for the blazing fast reply Filippo! I really appreciate it! :)
> On Mon, Sep 9, 2013 at 12:42 PM, Filippo Pisano
> <filippo.pisano at gmail.com> wrote:
> > You can simply md5 your key and query db for the md5 string corresponding
> > to your API request.
> So, are you saying that I should do something like:
> $transient_key =
> wp_hash("namespace_youtube:playlist_or_user|||cache_time|||number_of_items"
> , 'md5');
> In that case, could I drop "namespace_youtube:" and just md5 the rest
> for the key?
> Sorry if I'm asking silly questions ... I just want to make sure I'm
> following standard procedure here. :)
> Thanks so much!
> Cheers,
> M
> _______________________________________________
> 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