I've recently come across the Transients API in Wordpress in hopes of improving the performance of the plugin that I'm trying to write.
Basically the plugin is storing product details from the amazon product advertising API in the database. The product details are stored using the json encoded representation of the array.
Now I'm trying to use the transients API so that whenever the admin purges the database records it also updates using the transients API.
What I'm currently doing is storing the json encoded value using the set_transient
method. Something like this:
$data = array(
'123' => "{'title' : '', 'price' : '', 'brand' : ''}"
'456' => ...
);
$value = json_encode($data);
set_transient('amazon_items', $value, 60 * 60);
And then I get it from there using get_transient
$asin = '123';
$data = json_decode(get_transient('amazon_items'), true);
print_r($data[$asin]);
Is this ok or should I just store it in an array form so I can just directly access it without using json_decode
? Is my use case acceptable or is it overkill? Can I still improve this one? Is there a specific limit to how much data I can store using the transients API? In this particular use case I'm expecting it to be more than 50Mb of data.