[wp-hackers] Transient key best practice

Filippo Pisano filippo.pisano at gmail.com
Mon Sep 9 19:56:10 UTC 2013


On Mon, Sep 9, 2013 at 9: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?
>


Sure, you have to keep in mind that the DB column options.option_name is a
64 chars varchar and so you could not use such a long string (moreover when
using transients and additional record is created using your original
transient name + '_timeout'). Thus, IMO the hash technique should suits
your needs.



>
> Sorry if I'm asking silly questions ... I just want to make sure I'm
> following standard procedure here. :)
>

No silly question ;)


>
> 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