What to use , set_transient, set_option or file system? [closed]

I have a shortcode that can parse page contents. For example you give it a link to a GitHub md file , it reads it and saves the page content for you.

$parse_atts = array(
    'id'        => $id,
    'url'       => $url,
    'days'      => $days,
    'hours'     => $hours,
    'markdown'  => $markdown,
    'escaped'   => $escaped,
    'mdengine'  => $mdengine,
);
echo thz_parse_page( $parse_atts );

Issue I have is that I dont know what the best way of saving this data is. Some say dont use transient , some dont save the data and so on.

I have made a code for each, save as transient , save as option or save as txt file in uploads dir. The shortcode itself gives you an option to choose the expire time so removal of the data will occur either way.

The way I utilize the shortcode is for docs. All docs are hosted on GitHub and with the shortcode I can display parsed doc md in WordPress post. When cache time expires transient,option,file is deleted and new data resaved.

All WP coding standards are followed and nothing is retrieved outside of WP scope. There are no issues I see. Only the one asked.

Any help is appreciated.

1 Answer
1

I would go with transient. The reason I would choose transient it is they are created exactly for your case. I know that you have your own removal functionality but why to repeat yourself? Another advantage would be that transient beneath use cache. If for some reason your will need to install object cache your shortcode would automatically benefit from it.

Leave a Comment